Csharp indept notes

= Chapter 8 =

Object Initializers
 Normal initializer 

 version 2 - object initializer 

Collection initializer
 Normal collection initializer 

 Collection initializer 


 * 1)  These initializers are used in unit testing

Anonymous types

 * 1) Anonymous types are immutable
 * 2) public readonly properties, private readonly properties to back them up
 * 3) Overrides Equals, Gethashcode, ToString methods
 * 4) C# compiler treats types with same name and type on annon types as the same

Projection initializers
Instead of

We can use

The anonymous type will automatically use 'Name' as its property

= chapter 9 - Lamdas and expressions =

Introduction to Func<...> delegate types
For example, Func is equivalent to a delegate type of the form delegate int SomeDelegate(string arg1, double arg2)


 * 1) Func<> delegate types always return something. And accepts upto 4 parameters
 * 2) Action<...> delegate acts just like Func but they return void

First transformation from delegate to lamda expression
Below code shows we use lamda in the place of delegate