[C#基礎]-介面教學/應用
拷貝來源:http://msdn.microsoft.com/zh-tw/library/ms173156.aspx
interface IEquatable<T> { bool Equals(T obj); } public class Car : IEquatable<Car> { public string Make {get; set;} public string Model { get; set; } public string Year { get; set; }
// Implementation of IEquatable<T> interface public bool Equals(Car car) { if (this.Make == car.Make && this.Model == car.Model && this.Year == car.Year) { return true; } else return false; } }
|
沒有留言:
張貼留言