积极答复者
[帮忙] object.equal也会出错。。

问题
答案
-
namespace ConsoleApplicationZhiShu
{
public class Student
{
public int Id { get; set; }
public string Name { get; set; }public override bool Equals(object obj)
{
Student stu = obj as Student;
return (stu != null && stu.Id == this.Id && stu.Name == this.Name);
}
}
public class Eratosthenes
{static void Main(string[] args)
{
Student s = new Student { Id = 1, Name = "s" };
Student s2 = new Student { Id = 1, Name = "s" };
Console.WriteLine(s.Equals(s2));
}
}
}
如果你有其它意见或私下交流,请发送邮件到:maledong@qq.com;或者请
下载MSDN桌面工具(Vista,Win7)
下载Technet桌面小工具(Vista,Win7)
慈善点击,点击此处- 已标记为答案 tssing 2011年6月7日 4:28
全部回复
-
namespace ConsoleApplicationZhiShu
{
public class Student
{
public int Id { get; set; }
public string Name { get; set; }public override bool Equals(object obj)
{
Student stu = obj as Student;
return (stu != null && stu.Id == this.Id && stu.Name == this.Name);
}
}
public class Eratosthenes
{static void Main(string[] args)
{
Student s = new Student { Id = 1, Name = "s" };
Student s2 = new Student { Id = 1, Name = "s" };
Console.WriteLine(s.Equals(s2));
}
}
}
如果你有其它意见或私下交流,请发送邮件到:maledong@qq.com;或者请
下载MSDN桌面工具(Vista,Win7)
下载Technet桌面小工具(Vista,Win7)
慈善点击,点击此处- 已标记为答案 tssing 2011年6月7日 4:28