Hi Guys
NP77 GetHashCode()
Following program when executed in the Microsoft Visual Studio .NET 2003 environment is giving Hash code: 2 as an output.
When executed in the Microsoft Visual 2005 Express Edition environment is giving Hash code: 58225482 as an output.
What is the reason for different output? Anyone knows please explain the reason.
Thank you
using System;
class ObjTest
{
public static int Main(string[] args)
// Make an instance of ObjTest.
ObjTest c1 = new ObjTest();
// Pump info to console.
Console.WriteLine("ToString: {0} ", c1.ToString());
Console.WriteLine("Hash code: {0} ", c1.GetHashCode());
Console.WriteLine("Base class: {0} ", c1.GetType().BaseType);
// Make some other references to c1.
ObjTest c2 = c1;
object o = c2;
// Are all 3 instances pointing to the same object in memory?
if (o.Equals(c1) && c2.Equals(o))
Console.WriteLine("Same instance!");
return 0;
}