1. Anonymous type (can be used to encapsulate a set of read-only properties into a single object without having to explicitly define a type first)
?
var v = new { Amount = 108, Message = "Hello" }; Console.WriteLine(v.Amount); Console.WriteLine(v.Message); |
2. Automatic attributes (use automatic attributes no longer create local variables and accessors as in the past, you can simplify the code)
?
publi C class book {      public string bookname { get ; set ;}      public string IBSN { get set ;} |
3, anonymous delegate (do not create a new method to create a delegate)
?
List<
string
> list =
new List<
string
>(
new string
[] {
"str1"
,
"str2" });
string fstr = list.Find(
delegate
(
string str)
{
return str ==
"str1"
;
});
|
3. Lambda expression (simplifies the way anonymous delegates are written)
?
List< string > list = new List< string >( new string [] { "str1" , "str2" }); string fstr = list.Find(str => str == "str1" ); |
New functions and applications of c#4.0 language (1)