public override bool Equals(object obj) { AnonymousType0 <TName, TPrice> other = obj as AnonymousType0 <TName, TPrice>; return(other != null && EqualityComparer <TName> .Default.Equals(this.name, other.name) && EqualityComparer <TPrice> .Default.Equals(this.price, other.price)); }
static void Main(string[] args) { //var p = new { Count = 10, Title = "Anders" }; //Console.WriteLine(p.Title + ": " + p.Count); // 출력 결과: Anders: 10 // 익명 클래스 구문은 C# 컴파일러가 생성한 타입을 사용하는 구문으로 확장됨 var p = new AnonymousType0 <int, string>(10, "test"); }
static void Main(string[] args) { var p = new AnonymousType0 <int, string>(10, "test"); }