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. General Programming
  3. C#
  4. how to IF?!

how to IF?!

Scheduled Pinned Locked Moved C#
questiontutorial
31 Posts 7 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.
  • A AspDotNetDev

    I had a nice long reply I was working on, but my Internet decided to go down just as I posted it. So, lucky for you, you get the short version instead:

    ((a.L>0)==(b.L>0)).S();

    ;P

    [Forum Guidelines]

    L Offline
    L Offline
    Luc Pattyn
    wrote on last edited by
    #22

    why would you need a long reply to come up with a succinct code snippet? Anyway, with a real pre-processor, it is trivial:

    T

    :)

    Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


    Getting an article published on CodeProject should be easier and faster for Bronze and Silver authors.


    A 1 Reply Last reply
    0
    • A AspDotNetDev

      harold aptroot wrote:

      he never said anything about that

      FYI, my impression is that the OP wants either both to be filled in or neither to be filled in. Filling in one without filling in the other is not allowed.

      [Forum Guidelines]

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #23

      Ok, I think he just said that he wants a truth table like this:

      D S result
      0 0 1
      0 1 1
      1 0 0
      1 1 1

      IOW "everything is OK except skipping the second textbox after filling in the first" The smallest formula for that truth table is, AFAIK, (¬D)v S (where v is OR) Or maybe I'm just taking his explanation too literally..

      A 1 Reply Last reply
      0
      • L Luc Pattyn

        why would you need a long reply to come up with a succinct code snippet? Anyway, with a real pre-processor, it is trivial:

        T

        :)

        Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


        Getting an article published on CodeProject should be easier and faster for Bronze and Silver authors.


        A Offline
        A Offline
        AspDotNetDev
        wrote on last edited by
        #24

        If my Internet didn't go down, you'd know. ;P Why use a letter with such a high ASCII value? This seems more optimal:

        A

        As a bonus, your left pinky is already on that letter. :rolleyes:

        [Forum Guidelines]

        P 1 Reply Last reply
        0
        • L Lost User

          Ok, I think he just said that he wants a truth table like this:

          D S result
          0 0 1
          0 1 1
          1 0 0
          1 1 1

          IOW "everything is OK except skipping the second textbox after filling in the first" The smallest formula for that truth table is, AFAIK, (¬D)v S (where v is OR) Or maybe I'm just taking his explanation too literally..

          A Offline
          A Offline
          AspDotNetDev
          wrote on last edited by
          #25

          The OP said "one textbox is not null then the other should not be null as well". Order of the textboxes is never stated or implied. So "0 1" and "1 0" should have the same result ("0").

          [Forum Guidelines]

          L 1 Reply Last reply
          0
          • A AspDotNetDev

            The OP said "one textbox is not null then the other should not be null as well". Order of the textboxes is never stated or implied. So "0 1" and "1 0" should have the same result ("0").

            [Forum Guidelines]

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #26

            Interpretation. The OP should reply and clear this up..

            A 1 Reply Last reply
            0
            • L Lost User

              Interpretation. The OP should reply and clear this up..

              A Offline
              A Offline
              AspDotNetDev
              wrote on last edited by
              #27

              harold aptroot wrote:

              The OP should reply and clear this up

              The OP already did that:

              jrahma wrote:

              if the user entered BP_S then he MUST enter BP_D similarly, if the user entered BP_D then he MUST enter BP_S but user can leave both BP_S and BP_D as NULL

              Let's break that down...

              jrahma wrote:

              if the user entered BP_S then he MUST enter BP_D

              That means:

              If the first textbox contains some text, the second textbox must contain some text.

              jrahma wrote:

              if the user entered BP_D then he MUST enter BP_S

              That means:

              If the second textbox contains some text, the first textbox must contain some text.

              jrahma wrote:

              user can leave both BP_S and BP_D as NULL

              That means:

              If both are empty, that is fine.

              What all of that means: It is valid for both to be empty or both to contain text, but it is not ok for just one but not the other to contain text. That is my interpretation. But it is also the correct interpretation. I think the OP has everything he needs, but feel free to ask him if you don't think that's the case.

              [Forum Guidelines]

              L 1 Reply Last reply
              0
              • A AspDotNetDev

                harold aptroot wrote:

                The OP should reply and clear this up

                The OP already did that:

                jrahma wrote:

                if the user entered BP_S then he MUST enter BP_D similarly, if the user entered BP_D then he MUST enter BP_S but user can leave both BP_S and BP_D as NULL

                Let's break that down...

                jrahma wrote:

                if the user entered BP_S then he MUST enter BP_D

                That means:

                If the first textbox contains some text, the second textbox must contain some text.

                jrahma wrote:

                if the user entered BP_D then he MUST enter BP_S

                That means:

                If the second textbox contains some text, the first textbox must contain some text.

                jrahma wrote:

                user can leave both BP_S and BP_D as NULL

                That means:

                If both are empty, that is fine.

                What all of that means: It is valid for both to be empty or both to contain text, but it is not ok for just one but not the other to contain text. That is my interpretation. But it is also the correct interpretation. I think the OP has everything he needs, but feel free to ask him if you don't think that's the case.

                [Forum Guidelines]

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #28

                Oh lol. I forgot about that post

                N 1 Reply Last reply
                0
                • L Lost User

                  Oh lol. I forgot about that post

                  N Offline
                  N Offline
                  NavnathKale
                  wrote on last edited by
                  #29

                  You should first read the chain of responses before reply to anything. Yes its not in succinct way but I wrote it for people like you to understand who cant do proper requirement gathering or forgets about what the requirement is ;P

                  L 1 Reply Last reply
                  0
                  • N NavnathKale

                    You should first read the chain of responses before reply to anything. Yes its not in succinct way but I wrote it for people like you to understand who cant do proper requirement gathering or forgets about what the requirement is ;P

                    L Offline
                    L Offline
                    Lost User
                    wrote on last edited by
                    #30

                    Meh.. it was 3AM both times I posted that shit

                    1 Reply Last reply
                    0
                    • A AspDotNetDev

                      If my Internet didn't go down, you'd know. ;P Why use a letter with such a high ASCII value? This seems more optimal:

                      A

                      As a bonus, your left pinky is already on that letter. :rolleyes:

                      [Forum Guidelines]

                      P Offline
                      P Offline
                      PIEBALDconsult
                      wrote on last edited by
                      #31

                      I suspect the energy saving comes from having fewer 1-bits.

                      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