Finding a beginning is always a little subjective in computer books. This is
because so many things depend on so many other things. Often, the best we can
do is put a stake in the ground and start from that point. Anonymous types
are our stake.
Anonymous types use the keyword var. Var is an interesting choice because it
is still used in Pascal and Delphi today, but var in Delphi is like ByRef in
Visual Basic (VB) or ref in C#. The var introduced with .NET 3.5 indicates an
anonymous type. Now, our VB friends are going to think, "Well, we have had
variants for years; big deal." But var is not a dumbing down and clogging up
of C#. Anonymous types are something new and necessary.
Before looking at anonymous types, let's put a target on our end goal. Our
end goal is to master LINQ (integrated queries) in C# for objects, Extensible
Markup Language (XML), and data. We want... (more)