October 2010
Intermediate to advanced
1920 pages
73h 55m
English
Anonymous types is another idea that might be familiar to you from dynamic languages. Anonymous types are useful when you need a transient, fleeting type and you don’t want to do the work to create a class.
Here’s an example of creating an anonymous type in C#:
var customer = new {FirstName = "Stephen", LastName = "Walther"};
Here’s how you would create the same anonymous type in VB.NET:
Dim customer = New With {.FirstName = "Stephen", .LastName = "Walther"}
The customer variable is used without specifying a type, which looks very much like JavaScript or VBScript. However, you need to understand that customer does have a type; you just don’t know its name: It’s anonymous.
In a single line of code, we’ve managed to ...
Read now
Unlock full access