Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

GetHashCode returns zero: supposed bug?

bug gethashcode

  • Please log in to reply
No replies to this topic

#1 Mario Vernari

Mario Vernari

    Advanced Member

  • Members
  • PipPipPip
  • 1768 posts
  • LocationVenezia, Italia

Posted 17 May 2014 - 06:27 AM

I bumped against this issue, that is driving me crazy:

 

    public class Program
    {

        static object _a;
        object _c;

        public static void Main()
        {
            _a = new object();
            int ha = _a.GetHashCode();
            Debug.Print(ha.ToString());


            var b = new object();
            int hb = b.GetHashCode();
            Debug.Print(hb.ToString());


            var p = new Program();
            p._c = new object();
            int hc = p._c.GetHashCode();
            Debug.Print(hc.ToString());


            while (true)
            {
                Thread.Sleep(1000);
            }
        }
    }
The displayed result is zero in all three the tests. My suspect is about a bug in the framework: the mine is 4.2.
However, the GetHashCode *not always* seems buggy: still not clear, but "sometimes" returns a valid value (i.e. non-zero integer).
 
Can anyone confirm me whether is it a bug?
Is there anyone may try the above snippet with a more recent (e.g. latest) Netduino firmware?
 
Thanks everybody!
 
UPDATE: the objects comparison yields (correctly) a "false" result:
 
            Debug.Print((_a == b).ToString());
???

Edited by Mario Vernari, 17 May 2014 - 07:02 AM.

Biggest fault of Netduino? It runs by electricity.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.