Language Enhancements
Several .NET language enhancements were introduced with .NET 3.5. These language enhancements, along with features such as generics, are important pieces to building queries with LINQ.
This section will demonstrate and discuss several key language features, including:
Automatic property setters/getters
Object initializers
Collection initializers
Extension methods
Implicitly typed variables
Anonymous types
Figure 1-3 shows the .NET 3.5 language enhancements.

Figure 1-3. .NET 3.5 language enhancements at a glance
Automatic Properties in C#
Creating properties can be a very redundant process, especially when the getters and setters contain no logic other than getting and setting the value of the private field. Using public fields would reduce the amount of code; however, public fields do have some drawbacks. Most importantly, public fields are not fully supported by data binding.
One way to avoid having to type the code for a private field and
its public property getter and setter is to use a refactoring tool.
However, automatic properties allow you to type less code and still
get a private field and its public getter and setter. You create an
automatic property using shortened syntax. The compiler will generate
the private field and the public setter and getter for you. In Example 1-1, a Customer2 class and an Address2 class have several private fields that are exposed through ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access