using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication9
{
class Program
{
static void Main(string[] args)
{
Program a = new Program();
Program b = new Program();
if (a.Equals(b))
{
Console.WriteLine("a=b");
}
Console.WriteLine("a:{0}", a.GetHashCode());
Console.WriteLine("b:{0}", b.GetHashCode());
Program c = a;
if (a.Equals(c))
{
Console.WriteLine("a=c");
}
String str1 = new String("Hello".ToCharArray());
String str2 = new String("Hello".ToCharArray());
if (str1.Equals(str2))
{
Console.WriteLine("str1=str2");
}
if (str1==str2)
{
Console.WriteLine("str1=str2");
}
Console.WriteLine("str1:{0}", str1.GetHashCode());
Console.WriteLine("str2:{0}", str2.GetHashCode());
if (Object.ReferenceEquals(str1,str2))
{
Console.WriteLine("Object.ReferenceEquals(str1,str2)");
}
else
{
Console.WriteLine("Object.Reference not Equals(str1,str2)");
}
}
}
}
/*
a:46104728
b:12289376
a=c
str1=str2
str1=str2
str1:-694847
str2:-694847
Object.Reference not Equals(str1,str2)
请按任意键继续. . .
*/