Anonymous Types
As their name implies, anonymous types are .NET objects that have no previously defined type in the .NET Framework or your code and can be generated on-the-fly. They were first introduced with .NET Framework 3.5, and their main purpose is collecting data from LINQ queries. You prefer named types to anonymous types outside particular LINQ scenarios; however, it’s important to understand how anonymous types work. Declaring an anonymous type is straightforward, as shown in the following code snippet:
Dim anonymous = New With {.FirstName = "Alessandro", .LastName = "Del Sole", .Email = "", .Age = 37}
As you can see, no name for ...
Get Visual Basic 2015 Unleashed now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.