Anonymous types in VB NET - Key property

Anonymous types in VB NET – Key Property

Key properties have three main characteristics:

  • Only the values of key properties are compared in order to determine whether two instances are equal;
  • The values of key properties are read-only;
  • Only key property values are included in the compiler-generated hash code algorithm for an anonymous type;

Unit test example:

Result:

Anonymous type test results

Anonymous type test results