You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
691 B
C#
35 lines
691 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
|
|
namespace LinqStudy
|
|
{
|
|
/// <summary>
|
|
/// 重写比较方法的学生类
|
|
/// </summary>
|
|
public class StudentOverriteEquals
|
|
{
|
|
public int Id { get; set; }
|
|
|
|
public string Name { get; set; }
|
|
|
|
public int Age { get; set; }
|
|
|
|
public override bool Equals(object obj)
|
|
{
|
|
var other = obj as StudentOverriteEquals;
|
|
if (other == null)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
return Id == other.Id;
|
|
}
|
|
|
|
public override int GetHashCode()
|
|
{
|
|
return this.Id.GetHashCode();
|
|
}
|
|
}
|
|
}
|