IF Statements

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Chuck831

    #1

    IF Statements

    Hi, I'm still new to C# and haven't been able to find an solution to an IF
    statement problem. Is it possible to use an OR condition in an IF statement,
    i.e

    if (fileExtention == ".tmp" or fileExtention == ".lsi")
    {
    other statements go here.....
    }

    Thank you


  • Jochen Kalmbach [MVP]

    #2
    Re: IF Statements

    Hi Chuck831![color=blue]
    > Hi, I'm still new to C# and haven't been able to find an solution to an IF
    > statement problem. Is it possible to use an OR condition in an IF statement,
    > i.e
    >
    > if (fileExtention == ".tmp" or fileExtention == ".lsi")
    > {
    > other statements go here.....
    > }[/color]

    Try:

    if ( (fileExtention == ".tmp") || (fileExtention == ".lsi")) )
    {
    // other statements go here.....
    }

    For AND use "&&"

    --
    Greetings
    Jochen

    My blog about Win32 and .NET

    Comment

    • Chuck831

      #3
      Re: IF Statements

      John - Thank you

      "Jochen Kalmbach [MVP]" wrote:
      [color=blue]
      > Hi Chuck831![color=green]
      > > Hi, I'm still new to C# and haven't been able to find an solution to an IF
      > > statement problem. Is it possible to use an OR condition in an IF statement,
      > > i.e
      > >
      > > if (fileExtention == ".tmp" or fileExtention == ".lsi")
      > > {
      > > other statements go here.....
      > > }[/color]
      >
      > Try:
      >
      > if ( (fileExtention == ".tmp") || (fileExtention == ".lsi")) )
      > {
      > // other statements go here.....
      > }
      >
      > For AND use "&&"
      >
      > --
      > Greetings
      > Jochen
      >
      > My blog about Win32 and .NET
      > http://blog.kalmbachnet.de/
      >[/color]

      Comment

      • Peter Koch Larsen

        #4
        Re: IF Statements


        "Jochen Kalmbach [MVP]" <nospam-Jochen.Kalmbach @holzma.de> skrev i en
        meddelelse news:%23AjOUQBq FHA.2816@tk2msf tngp13.phx.gbl. ..[color=blue]
        > Hi Chuck831![color=green]
        >> Hi, I'm still new to C# and haven't been able to find an solution to an
        >> IF statement problem. Is it possible to use an OR condition in an IF
        >> statement, i.e if (fileExtention == ".tmp" or fileExtention == ".lsi")
        >> {
        >> other statements go here.....
        >> }[/color]
        >
        > Try:
        >
        > if ( (fileExtention == ".tmp") || (fileExtention == ".lsi")) )
        > {
        > // other statements go here.....
        > }
        >
        > For AND use "&&"
        >
        > --
        > Greetings
        > Jochen
        >
        > My blog about Win32 and .NET
        > http://blog.kalmbachnet.de/[/color]

        and and or are C++ keywords - one of the remaining places where Microsoft
        hasn't yet become compatible.

        /Peter


        Comment

        • Bo Persson

          #5
          Re: IF Statements


          "Peter Koch Larsen" <pkl@mailme.d k> skrev i meddelandet
          news:OJDECQcqFH A.3016@TK2MSFTN GP12.phx.gbl...[color=blue]
          >
          > "Jochen Kalmbach [MVP]" <nospam-Jochen.Kalmbach @holzma.de> skrev i
          > en meddelelse news:%23AjOUQBq FHA.2816@tk2msf tngp13.phx.gbl. ..[color=green]
          >> Hi Chuck831![color=darkred]
          >>> Hi, I'm still new to C# and haven't been able to find an solution
          >>> to an IF statement problem. Is it possible to use an OR condition
          >>> in an IF statement, i.e if (fileExtention == ".tmp" or
          >>> fileExtention == ".lsi")
          >>> {
          >>> other statements go here.....
          >>> }[/color]
          >>
          >> Try:
          >>
          >> if ( (fileExtention == ".tmp") || (fileExtention == ".lsi")) )
          >> {
          >> // other statements go here.....
          >> }
          >>
          >> For AND use "&&"
          >>
          >> --
          >> Greetings
          >> Jochen
          >>
          >> My blog about Win32 and .NET
          >> http://blog.kalmbachnet.de/[/color]
          >
          > and and or are C++ keywords - one of the remaining places where
          > Microsoft hasn't yet become compatible.[/color]

          It's an extension *not* to have the keywords. :-)

          If you choose Disable Microsoft Extensions, and and or works
          according to the standard.


          Bo Persson


          Comment

          Working...