August 2008
Intermediate to advanced
197 pages
3h 23m
English
In Listing 1-1, note that no type was specified after the new keyword in the object initialization expression. The compiler created a locally scoped anonymous type for us.
Anonymous types let us work with query results on the fly without having to explicitly define classes to represent them. When the compiler encountered
select new { p.FirstName, p.LastName };
in Listing 1-1 it transparently created a new class with two properties, one for each parameter (see Listing 1-7).
internal class ???
{
private string _firstName;
private string _lastName;
public string FirstName { get { return _firstName; } set { firstName = value; } } public string LastName { get { return _lastName; } set ... |
Read now
Unlock full access