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.
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