Skip to content

Anonymous Types

Mario Gutierrez edited this page Jan 8, 2017 · 4 revisions
  • Anonymous types override ToString(), GetHashCode(), and Equals() to
    perform value-based equality checking.
  • The == operator compares by reference though.
  • Properties of an anonymous type are read-only.

Example:

var anon = new { Title = "Hello", Author = "Unknown" };
Clone this wiki locally