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. The Lounge
  3. dotNET Rant [modified]

dotNET Rant [modified]

Scheduled Pinned Locked Moved The Lounge
questioncsharpcomlearning
101 Posts 25 Posters 16 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.
  • L Lost User

    Is has to be like that, though. Otherwise either the "a.Equals(a) must be true" identity is violated (which would make some of the non-generic .NET 1.1 collections fail*), or the rules for IEEE floating point comparison are.. * you could put a NaN into an ArrayList and then use Contains, only to find that the NaN has "disappeared" but is still taking up a slot somewhere and you can clearly see it in the debugger.. :)

    modified on Thursday, May 6, 2010 7:35 PM

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

    Ian's next book could be titled "The Mystery of the Vanishing NaN" then? :)

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


    Prolific encyclopedia fixture proof-reader browser patron addict?
    We all depend on the beast below.


    A 1 Reply Last reply
    0
    • T TheGreatAndPowerfulOz

      The context is comparing DbParameter's (parameters to a PreparedCommand) to know whether the result is cached or not. So it's not as simple as it may seem. In any case, seems to me that since only primitives get boxed, then that condition should be checked in the object.Equals code. Thanks for the suggestion.

      Fight Big Government:
      http://obamacareclassaction.com/
      http://obamacaretruth.org/

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

      ahmed zahmed wrote:

      since only primitives get boxed

      only value types get boxed, i.e. when an object is required. I wouldn't call a struct primitive. :)

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


      Prolific encyclopedia fixture proof-reader browser patron addict?
      We all depend on the beast below.


      T 1 Reply Last reply
      0
      • L Luc Pattyn

        To complicate matters: you do know some of those strings will be interned, and some won't. Now this thread is more technical than any of today's threads in the C# forum. It is time you realize this still is The Lounge. :)

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


        Prolific encyclopedia fixture proof-reader browser patron addict?
        We all depend on the beast below.


        R Offline
        R Offline
        Rama Krishna Vavilala
        wrote on last edited by
        #42

        Yes that's why I did not do: :)

        string s = "ahmed";
        String s1 = "ahmed";

        1 Reply Last reply
        0
        • T TheGreatAndPowerfulOz

          ok, this is not a programming question. It's a rant! given,

          object one = 0;
          object two = 0;
          bool same = one == two;

          what would you expect the value of same to be? WRONG! it's false! Whoever thought that was a valid result, is cracked!:mad::mad::mad::mad::mad: [edit] so, after going home and resting my brain a bit. it seems as though i'm the one that was cracked. thanks for the refresher course everyone. it is of course doing a reference comparison. which is correct. you all know how it is when you struggle with something and get too close to the trees to see the forest. anyway thanks to everyone for being your normally brutally honest selves. cheers. :-D [/edit]

          Fight Big Government:
          http://obamacareclassaction.com/
          http://obamacaretruth.org/

          modified on Friday, May 7, 2010 1:08 AM

          S Offline
          S Offline
          Scott Dorman
          wrote on last edited by
          #43

          I would expect it to be false. You are comparing two object instances for reference equality, and clearly one is not in the same memory location as two.

          Scott Dorman

          Microsoft® MVP - Visual C# | MCPD President - Tampa Bay IASA [Blog][Articles][Forum Guidelines]


          Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai

          T 1 Reply Last reply
          0
          • T TheGreatAndPowerfulOz

            Rama Krishna Vavilala wrote:

            It has to be false. What else can it be?

            Why? One would expect that the comparators of the boxed values would be used. so, the result would be true, as I initially expected. I understand what's happening, but I don't understand why the dotNETtors decided this was correct.

            Fight Big Government:
            http://obamacareclassaction.com/
            http://obamacaretruth.org/

            S Offline
            S Offline
            Scott Dorman
            wrote on last edited by
            #44

            ahmed zahmed wrote:

            One would expect that the comparators of the boxed values would be used. so, the result would be true, as I initially expected.

            Why do you think these are being boxed? You are clearly assigning values to an object instance. This doesn't result in any boxing operations.

            Scott Dorman

            Microsoft® MVP - Visual C# | MCPD President - Tampa Bay IASA [Blog][Articles][Forum Guidelines]


            Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai

            T 1 Reply Last reply
            0
            • T TheGreatAndPowerfulOz

              ok, this is not a programming question. It's a rant! given,

              object one = 0;
              object two = 0;
              bool same = one == two;

              what would you expect the value of same to be? WRONG! it's false! Whoever thought that was a valid result, is cracked!:mad::mad::mad::mad::mad: [edit] so, after going home and resting my brain a bit. it seems as though i'm the one that was cracked. thanks for the refresher course everyone. it is of course doing a reference comparison. which is correct. you all know how it is when you struggle with something and get too close to the trees to see the forest. anyway thanks to everyone for being your normally brutally honest selves. cheers. :-D [/edit]

              Fight Big Government:
              http://obamacareclassaction.com/
              http://obamacaretruth.org/

              modified on Friday, May 7, 2010 1:08 AM

              D Offline
              D Offline
              Dave Kreskowiak
              wrote on last edited by
              #45

              Of course it's false! You just compared the references of two OBJECTS, not two values. It seems that you're the one who's "cracked".

              A guide to posting questions on CodeProject[^]
              Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                   2006, 2007, 2008
              But no longer in 2009...

              T 1 Reply Last reply
              0
              • L Luc Pattyn

                Ian's next book could be titled "The Mystery of the Vanishing NaN" then? :)

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


                Prolific encyclopedia fixture proof-reader browser patron addict?
                We all depend on the beast below.


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

                Luc Pattyn wrote:

                The Mystery of the Vanishing NaN

                It's no mystery that any NaaN placed in front of me will vanish.

                [Forum Guidelines]

                1 Reply Last reply
                0
                • T TheGreatAndPowerfulOz

                  ok, this is not a programming question. It's a rant! given,

                  object one = 0;
                  object two = 0;
                  bool same = one == two;

                  what would you expect the value of same to be? WRONG! it's false! Whoever thought that was a valid result, is cracked!:mad::mad::mad::mad::mad: [edit] so, after going home and resting my brain a bit. it seems as though i'm the one that was cracked. thanks for the refresher course everyone. it is of course doing a reference comparison. which is correct. you all know how it is when you struggle with something and get too close to the trees to see the forest. anyway thanks to everyone for being your normally brutally honest selves. cheers. :-D [/edit]

                  Fight Big Government:
                  http://obamacareclassaction.com/
                  http://obamacaretruth.org/

                  modified on Friday, May 7, 2010 1:08 AM

                  M Offline
                  M Offline
                  Marc Clifton
                  wrote on last edited by
                  #47

                  ahmed zahmed wrote:

                  Whoever thought that was a valid result, is cracked

                  Well duh, it's supposed to be different, you're one who's cracked! Why don't you read up on value vs. reference comparisons. Marc

                  T T 2 Replies Last reply
                  0
                  • T TheGreatAndPowerfulOz

                    obviously, my statement was an opinion. but, i'll deal with reality rather than my wishfulness.

                    Fight Big Government:
                    http://obamacareclassaction.com/
                    http://obamacaretruth.org/

                    M Offline
                    M Offline
                    Marc Clifton
                    wrote on last edited by
                    #48

                    ahmed zahmed wrote:

                    my statement was an opinion

                    No, your statement is not an opinion, it is a falsehood. Much like the return of your two object comparison, hahaha. Marc

                    T 1 Reply Last reply
                    0
                    • M Marc Clifton

                      ahmed zahmed wrote:

                      my statement was an opinion

                      No, your statement is not an opinion, it is a falsehood. Much like the return of your two object comparison, hahaha. Marc

                      T Offline
                      T Offline
                      TheGreatAndPowerfulOz
                      wrote on last edited by
                      #49

                      nice. hope you feel good about yourself.

                      Fight Big Government:
                      http://obamacareclassaction.com/
                      http://obamacaretruth.org/

                      1 Reply Last reply
                      0
                      • L Luc Pattyn

                        ahmed zahmed wrote:

                        since only primitives get boxed

                        only value types get boxed, i.e. when an object is required. I wouldn't call a struct primitive. :)

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


                        Prolific encyclopedia fixture proof-reader browser patron addict?
                        We all depend on the beast below.


                        T Offline
                        T Offline
                        TheGreatAndPowerfulOz
                        wrote on last edited by
                        #50

                        yes, true enough. still in the context where i'm dealing with these boxed "value types" the only values boxed will be primitives. but thanks for the reminder.

                        Fight Big Government:
                        http://obamacareclassaction.com/
                        http://obamacaretruth.org/

                        1 Reply Last reply
                        0
                        • S Scott Dorman

                          I would expect it to be false. You are comparing two object instances for reference equality, and clearly one is not in the same memory location as two.

                          Scott Dorman

                          Microsoft® MVP - Visual C# | MCPD President - Tampa Bay IASA [Blog][Articles][Forum Guidelines]


                          Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai

                          T Offline
                          T Offline
                          TheGreatAndPowerfulOz
                          wrote on last edited by
                          #51

                          yes, a distinction i forgot in my frustration. thanks for the refresher.

                          Fight Big Government:
                          http://obamacareclassaction.com/
                          http://obamacaretruth.org/

                          1 Reply Last reply
                          0
                          • M Marc Clifton

                            ahmed zahmed wrote:

                            Whoever thought that was a valid result, is cracked

                            Well duh, it's supposed to be different, you're one who's cracked! Why don't you read up on value vs. reference comparisons. Marc

                            T Offline
                            T Offline
                            TheGreatAndPowerfulOz
                            wrote on last edited by
                            #52

                            lol, yep you are right. that's me, the cracked one.

                            Fight Big Government:
                            http://obamacareclassaction.com/
                            http://obamacaretruth.org/

                            1 Reply Last reply
                            0
                            • D Dave Kreskowiak

                              Of course it's false! You just compared the references of two OBJECTS, not two values. It seems that you're the one who's "cracked".

                              A guide to posting questions on CodeProject[^]
                              Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                                   2006, 2007, 2008
                              But no longer in 2009...

                              T Offline
                              T Offline
                              TheGreatAndPowerfulOz
                              wrote on last edited by
                              #53

                              well, you know how it is, i'm sure when you're doing something all day long and your brain gets fried. yep, i was the one cracked, for sure.

                              Fight Big Government:
                              http://obamacareclassaction.com/
                              http://obamacaretruth.org/

                              1 Reply Last reply
                              0
                              • S Scott Dorman

                                ahmed zahmed wrote:

                                One would expect that the comparators of the boxed values would be used. so, the result would be true, as I initially expected.

                                Why do you think these are being boxed? You are clearly assigning values to an object instance. This doesn't result in any boxing operations.

                                Scott Dorman

                                Microsoft® MVP - Visual C# | MCPD President - Tampa Bay IASA [Blog][Articles][Forum Guidelines]


                                Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai

                                T Offline
                                T Offline
                                TheGreatAndPowerfulOz
                                wrote on last edited by
                                #54

                                ok, perhaps I'm misunderstanding something, but aren't value types boxed when assigned to an object? or passed as a parameter to a function whose parameter type is object?

                                Fight Big Government:
                                http://obamacareclassaction.com/
                                http://obamacaretruth.org/

                                S 1 Reply Last reply
                                0
                                • T TheGreatAndPowerfulOz

                                  ok, this is not a programming question. It's a rant! given,

                                  object one = 0;
                                  object two = 0;
                                  bool same = one == two;

                                  what would you expect the value of same to be? WRONG! it's false! Whoever thought that was a valid result, is cracked!:mad::mad::mad::mad::mad: [edit] so, after going home and resting my brain a bit. it seems as though i'm the one that was cracked. thanks for the refresher course everyone. it is of course doing a reference comparison. which is correct. you all know how it is when you struggle with something and get too close to the trees to see the forest. anyway thanks to everyone for being your normally brutally honest selves. cheers. :-D [/edit]

                                  Fight Big Government:
                                  http://obamacareclassaction.com/
                                  http://obamacaretruth.org/

                                  modified on Friday, May 7, 2010 1:08 AM

                                  A Offline
                                  A Offline
                                  Abhinav S
                                  wrote on last edited by
                                  #55

                                  ahmed zahmed wrote:

                                  so, after going home and resting my brain a bit. it seems as though i'm the one that was cracked. thanks for the refresher course everyone. it is of course doing a reference comparison. which is correct. you all know how it is when you struggle with something and get too close to the trees to see the forest. anyway thanks to everyone for being your normally brutally honest selves. cheers.

                                  When was the last time you took a vacation? This happens to me when I've not taken a vacation for too long......

                                  T 1 Reply Last reply
                                  0
                                  • T TheGreatAndPowerfulOz

                                    ok, this is not a programming question. It's a rant! given,

                                    object one = 0;
                                    object two = 0;
                                    bool same = one == two;

                                    what would you expect the value of same to be? WRONG! it's false! Whoever thought that was a valid result, is cracked!:mad::mad::mad::mad::mad: [edit] so, after going home and resting my brain a bit. it seems as though i'm the one that was cracked. thanks for the refresher course everyone. it is of course doing a reference comparison. which is correct. you all know how it is when you struggle with something and get too close to the trees to see the forest. anyway thanks to everyone for being your normally brutally honest selves. cheers. :-D [/edit]

                                    Fight Big Government:
                                    http://obamacareclassaction.com/
                                    http://obamacaretruth.org/

                                    modified on Friday, May 7, 2010 1:08 AM

                                    N Offline
                                    N Offline
                                    NormDroid
                                    wrote on last edited by
                                    #56

                                    Object comparison, answer is false.

                                    Two heads are better than one.

                                    1 Reply Last reply
                                    0
                                    • T TheGreatAndPowerfulOz

                                      ok, this is not a programming question. It's a rant! given,

                                      object one = 0;
                                      object two = 0;
                                      bool same = one == two;

                                      what would you expect the value of same to be? WRONG! it's false! Whoever thought that was a valid result, is cracked!:mad::mad::mad::mad::mad: [edit] so, after going home and resting my brain a bit. it seems as though i'm the one that was cracked. thanks for the refresher course everyone. it is of course doing a reference comparison. which is correct. you all know how it is when you struggle with something and get too close to the trees to see the forest. anyway thanks to everyone for being your normally brutally honest selves. cheers. :-D [/edit]

                                      Fight Big Government:
                                      http://obamacareclassaction.com/
                                      http://obamacaretruth.org/

                                      modified on Friday, May 7, 2010 1:08 AM

                                      C Offline
                                      C Offline
                                      CPallini
                                      wrote on last edited by
                                      #57

                                      You remember me Java newbies using the == operator with strings... :rolleyes:

                                      If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                                      This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
                                      [My articles]

                                      1 Reply Last reply
                                      0
                                      • T TheGreatAndPowerfulOz

                                        ok, this is not a programming question. It's a rant! given,

                                        object one = 0;
                                        object two = 0;
                                        bool same = one == two;

                                        what would you expect the value of same to be? WRONG! it's false! Whoever thought that was a valid result, is cracked!:mad::mad::mad::mad::mad: [edit] so, after going home and resting my brain a bit. it seems as though i'm the one that was cracked. thanks for the refresher course everyone. it is of course doing a reference comparison. which is correct. you all know how it is when you struggle with something and get too close to the trees to see the forest. anyway thanks to everyone for being your normally brutally honest selves. cheers. :-D [/edit]

                                        Fight Big Government:
                                        http://obamacareclassaction.com/
                                        http://obamacaretruth.org/

                                        modified on Friday, May 7, 2010 1:08 AM

                                        C Offline
                                        C Offline
                                        CurtainDog
                                        wrote on last edited by
                                        #58

                                        The deeper question is why does auto boxing not return the same object.

                                        D 1 Reply Last reply
                                        0
                                        • T TheGreatAndPowerfulOz

                                          ok, this is not a programming question. It's a rant! given,

                                          object one = 0;
                                          object two = 0;
                                          bool same = one == two;

                                          what would you expect the value of same to be? WRONG! it's false! Whoever thought that was a valid result, is cracked!:mad::mad::mad::mad::mad: [edit] so, after going home and resting my brain a bit. it seems as though i'm the one that was cracked. thanks for the refresher course everyone. it is of course doing a reference comparison. which is correct. you all know how it is when you struggle with something and get too close to the trees to see the forest. anyway thanks to everyone for being your normally brutally honest selves. cheers. :-D [/edit]

                                          Fight Big Government:
                                          http://obamacareclassaction.com/
                                          http://obamacaretruth.org/

                                          modified on Friday, May 7, 2010 1:08 AM

                                          P Offline
                                          P Offline
                                          Pete Appleton
                                          wrote on last edited by
                                          #59

                                          void* one = 0; void* two = 0; BOOL same = (one == two); // false - the lvalues of one and two are different BOOL sameValue = (*one == *two); // true - the rvalues are the same *one = 1; *two = 2; same = (one == two); // false - the lvalues are different sameValue = (*one == *two); // false - the rvalues are different now There's a reason why C# is called a C-based language... you may wish to brush up on your knowledge of pointers...

                                          -- What's a signature?

                                          N T 2 Replies 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