Dim myObject = New With { .id = 1, .type="dog", .name="hello" }
The compile will create and initialize a type for you.
With the "Key" keyword, it will allow you to select exactly which variables in an anonymous type should be used in either the calculation of a hashcode (using GetHashCode) or an equality comparison.
Dim myObject = New With {Key .id = 1, Key .type="dog", Key .name="hello" }
Dim myObject2 = New With {Key .id = 1, Key .type="dog", Key .name="hello" }
Console.WriteLine(myObject.GetHashCode)
Console.WriteLine(myObject .Equals(myObject2 ))
No comments:
Post a Comment