Automatic Property Declaration

This chapter will discuss automatic property declaration, which is a simplified syntax to declare a property for a class. I will also discuss the implicit variable declaration using the var keyword and show how var is handled by the C# compiler in design and runtime. Finally, I will discuss the anonymous type declaration and how the C# compiler compiles it.

Automatic Property

You can use the class of a real-world object to encapsulate its characteristics. For example, if you think about a real-life object, such as a book of class Book as demonstrated in Listing 5-1, you can see it has a name, a publication ...

Get Expert C# 5.0: with the .NET 4.5 Framework now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.