Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. How to use the 'OR' Condition

How to use the 'OR' Condition

Scheduled Pinned Locked Moved ASP.NET
csharptutorialquestion
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    Kurian_Kurian
    wrote on last edited by
    #1

    Hi,this is my code.how to use OR condition in c# code,this code is not working.i want to check the selected image extension.if the extension .jpg or .bmp then it is going to this condition code.what is wrong in that. if (System.IO.Path.GetExtension(cmdBrowse.FileName).ToLower() != ".jpg" | System.IO.Path.GetExtension(cmdBrowse.FileName).ToLower() != ".bmp")

    M D S 3 Replies Last reply
    0
    • K Kurian_Kurian

      Hi,this is my code.how to use OR condition in c# code,this code is not working.i want to check the selected image extension.if the extension .jpg or .bmp then it is going to this condition code.what is wrong in that. if (System.IO.Path.GetExtension(cmdBrowse.FileName).ToLower() != ".jpg" | System.IO.Path.GetExtension(cmdBrowse.FileName).ToLower() != ".bmp")

      M Offline
      M Offline
      Michael Sync
      wrote on last edited by
      #2

      Try ||.. e.g. if (System.IO.Path.GetExtension(cmdBrowse.FileName).ToLower() != ".jpg" || System.IO.Path.GetExtension(cmdBrowse.FileName).ToLower() != ".bmp")

      Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net)

      1 Reply Last reply
      0
      • K Kurian_Kurian

        Hi,this is my code.how to use OR condition in c# code,this code is not working.i want to check the selected image extension.if the extension .jpg or .bmp then it is going to this condition code.what is wrong in that. if (System.IO.Path.GetExtension(cmdBrowse.FileName).ToLower() != ".jpg" | System.IO.Path.GetExtension(cmdBrowse.FileName).ToLower() != ".bmp")

        D Offline
        D Offline
        Dave Doknjas
        wrote on last edited by
        #3

        Either || or | will work (although the non-short-circuiting single pipe is an odd choice here since it's more commonly used for bitwise or). Are you sure you don't want to test for equality rather than inequality? string lower = System.IO.Path.GetExtension(cmdBrowse.FileName).ToLower(); if (lower == ".jpg" || lower == ".bmp")

        David Anton http://www.tangiblesoftwaresolutions.com C++ to C# Converter C++ to VB Converter C++ to Java Converter C++ to C++/CLI Converter Instant C#: VB to C# converter Instant VB: C# to VB converter Instant C++: converts C# to C++/CLI and VB to C++/CLI

        1 Reply Last reply
        0
        • K Kurian_Kurian

          Hi,this is my code.how to use OR condition in c# code,this code is not working.i want to check the selected image extension.if the extension .jpg or .bmp then it is going to this condition code.what is wrong in that. if (System.IO.Path.GetExtension(cmdBrowse.FileName).ToLower() != ".jpg" | System.IO.Path.GetExtension(cmdBrowse.FileName).ToLower() != ".bmp")

          S Offline
          S Offline
          SunithaNallana
          wrote on last edited by
          #4

          I think u have to put 2 piping(||)characters in ur code It's like this.. if ((System.IO.Path.GetExtension(cmdBrowse.FileName).ToLower() != ".jpg") ||(System.IO.Path.GetExtension(cmdBrowse.FileName).ToLower() != ".bmp")) try this once...:)

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups