.Net 3.0/3.5/4.0 New Language Features
Auto Implemented Properties
1.Auto-implemented properties make property-declaration more concise when no additional logicis required in the property accessors.
When you declare a property the compiler creates a private, anonymous backing field can only beaccessed through the property's
Auto-implemented properties must declare both a
To create a readonly auto-implemented property, give it a private set accessor.5.It doesn’t improve the performance since the compiler will generate the same as the way what itgenerates for normal class that doesn’t have auto-implemented properties
6.Use auto implemented properties rather than the properties used in earlier version as itremoves extra lines of code and make it simpler.
Allow you to assign values to any field or properties of the object at creation time.
Initializes objects in a declarative manner without having to explicitly invoke a constructor.
1.Allows creating a collection and initializing it with a series of objects in a single statement.
Let you initialize a collection class consisting of various elements.
Element Initializers can be simple value, an expression or object initializer.
1.Extension methods enable you to "add" methods to existing types without creating a new derivedtype, recompiling, or otherwise modifying the original type.2.Extension methods are a special kind of static method, but they are called as if they were instancemethods on the extended type.3.Extension methods are defined as static methods but are called by using instance method syntax.
Their first parameter specifies which type the method operates on, and the parameter is preceded by the “
Extension methods are only in scope when you explicitly import the namespace into your sourcecode with a
Extension methods can only be declared in
classes.7.The first parameter of an extension method can only have this modifier (no other modifiers areallowed) and the parameter type cannot be a pointer type.8.Extension methods have lower precedence than regular instance methods on a type.
A lambda expression is an anonymous function that can contain expressions and statements, andcan be used to create delegates or expression tree types.2.All lambda expressions use the lambda operator =>, which read as “goes to”.i.E.g. x=> x * x read as x goes to x times x.3.The left side of the lambda operator specifies the input parameters (if any) and the right side holdthe expression or statement block.
One of the new features of C# 3.0 is the
keyword, which can be used to implicitly declare a