CSharp examples for Custom Type:Anonymous Types
Anonymous Types Equals method is overridden to perform equality comparisons:
using System;/*from w w w . j ava 2 s . c o m*/ class Test { static void Main() { var a1 = new { X = 2, Y = 4 }; var a2 = new { X = 2, Y = 4 }; Console.WriteLine (a1 == a2); // False Console.WriteLine (a1.Equals (a2)); // True } }