- 3.0 allows properties without local variables
- var (varient) - it is implicitly typed variable
- Anonymous variable
- Lamda expression
- FUNC<>
- Extention Method
Here is the detail:
1. C#3.0 allows properties without local variables:
Tip: Type prop in the visual studio and press tab2. Simple and implicitly typed local variable
- It is implicitly typed variable
- var i=10;
- var str="nidhish";
- var x="109"; // It is invalid. Compiler does not allow this.
- var CANNOT be used as a parameter or a return type. It is heavily used in LINQ
- it is helpful for object initialization
- Example:
List4. Lamda expression:mystring=new List {
"Item1",
"Item2",
"Item3"}
- Example:
delegate long myadd(int n1,int n2);
Public void TestLamda()
{
myadd ad= (n1,n2) => { return n1+n2; };
Console.WriteLine(ad.invoke(100,150));
}
5. Extending type with extension method
Extension method provide developers to extend the functionality of an existing type. Extension methods are static methods with keywork this
Eg: Extend string class with a reverse method
No comments:
Post a Comment