Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Save to My Library
Look up keyword
Like this
2Activity
0 of .
Results for:
No results containing your search query
P. 1
New Language Features

New Language Features

Ratings: (0)|Views: 284|Likes:
Published by Sreenivasarao

More info:

Published by: Sreenivasarao on Aug 27, 2009
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as DOCX, PDF, TXT or read online from Scribd
See more
See less

10/12/2012

pdf

text

original

 
.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.
2.
When you declare a property the compiler creates a private, anonymous backing field can only beaccessed through the property's
get
and
set
accessors.
3.
Auto-implemented properties must declare both a
get
and a
set
accessor.
4.
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.
Object Initializers
1.
Allow you to assign values to any field or properties of the object at creation time.
2.
Initializes objects in a declarative manner without having to explicitly invoke a constructor.
Collection Initializers
1.Allows creating a collection and initializing it with a series of objects in a single statement.
2.
Let you initialize a collection class consisting of various elements.
3.
Element Initializers can be simple value, an expression or object initializer.
Extension Methods
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.
4.
Their first parameter specifies which type the method operates on, and the parameter is preceded by the “
this”
modifier.
5.
Extension methods are only in scope when you explicitly import the namespace into your sourcecode with a
using
directive.
6.
Extension methods can only be declared in
static
,
non-generic
and
non-nested
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.
Lambda Expressions
 
1.
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.
“Var” keyword
1.
One of the new features of C# 3.0 is the
var
keyword, which can be used to implicitly declare a

You're Reading a Free Preview

Download
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->