日期:2014-05-16 浏览次数:20911 次
struct s
{
public int i;
public override bool Equals(object obj)
{
Console.WriteLine("Equanls");
return base.Equals(obj);
}
public static bool operator ==(s obj1, s obj2)
{
Console.WriteLine("operator==");
return obj1.i == obj2.i;
}
public static bool operator !=(s obj1, s obj2)
{
Console.WriteLine("operator!=");
return obj1.i != obj2.i;
}
}
static void Main(string[] args)
{
s st1 = new s();
st1.i = 0;
s st2 = st1;
Console.WriteLine(st1 == st2);
Console.WriteLine(st1 != st2);
}