Some New in C# 3.0 language
2008-04-11 09:58
399 查看
1 Automatic properties
public string Name ...{ get; set; }
2 Partial Methods ?
3 Object Initializers
TextBox t = new TextBox ...{Text="Hi", Multiline=true, Location = new Point(5,5), Size=new Size(50,100)};
4 Anonymous Types
var o = new ...{SomeField=DateTime.Now, AnotherField=5.6};
5 Extension methods (Should in static class )
Declare:
[Extension()]
public static bool IsAllUppercase(string s) .........{...}
// OR
public static bool IsAllUppercase(this string s) .........{...}
Usage
string str;
str.IsAllUppercase();
6 Lambda Expressions
delegate bool SomeDelegate(int i);
private void SomeMethod()
...{
SomeDelegate sd = delegate(int i)...{return i > 2;} ;
//Or SomeDelegate sd = i => i > 2;
YetOneMore(sd);
}
private void YetOneMore(SomeDelegate f)
...{
bool res = f(5);
Console.WriteLine(b.ToString());
}
Comes From Top 10 things to know about Visual Studio 2008 and .NET Framework 3.5 by Daniel Moth
PS: The Office 2003 templates in VS2008 attract me :)
public string Name ...{ get; set; }
2 Partial Methods ?
3 Object Initializers
TextBox t = new TextBox ...{Text="Hi", Multiline=true, Location = new Point(5,5), Size=new Size(50,100)};
4 Anonymous Types
var o = new ...{SomeField=DateTime.Now, AnotherField=5.6};
5 Extension methods (Should in static class )
Declare:
[Extension()]
public static bool IsAllUppercase(string s) .........{...}
// OR
public static bool IsAllUppercase(this string s) .........{...}
Usage
string str;
str.IsAllUppercase();
6 Lambda Expressions
delegate bool SomeDelegate(int i);
private void SomeMethod()
...{
SomeDelegate sd = delegate(int i)...{return i > 2;} ;
//Or SomeDelegate sd = i => i > 2;
YetOneMore(sd);
}
private void YetOneMore(SomeDelegate f)
...{
bool res = f(5);
Console.WriteLine(b.ToString());
}
Comes From Top 10 things to know about Visual Studio 2008 and .NET Framework 3.5 by Daniel Moth
PS: The Office 2003 templates in VS2008 attract me :)
相关文章推荐
- What's New in the C# 3.0 Language and Compiler
- A new way to perform parameter validation in C# 3.0
- C# 3.0 New Language Features (Part 1)
- C# 3.0 New Language Features (Part 2)
- C# 3.0 New Language Features (Part 2)
- Some New Features in C# 6.0
- New feature in C# 3.0 - aims to make data programmable in a general purpose and truly object oriented syntax
- New Features in C# 3.0
- Some New Features in C# 6.0
- New Features in C# 3.0, 4.0 and 5.0 (英文差的免入)
- New Language Features in C# 6
- C# 3.0 New Language Features (Part 1)
- [Tip: C# in VS]Some quick tips for working on C# in VS
- 【翻译】Pro LINQ Language Integrated Query in C# 2008 -- 目录
- 【翻译】Pro LINQ Language Integrated Query in C# 2008 -- 第三章 (LINQ TO Objects) 第一节
- 【翻译】Pro LINQ Language Integrated Query in C# 2008 -- 第三章 (LINQ TO Objects) 第二节
- 【翻译】Pro LINQ Language Integrated Query in C# 2008 -- 第三章 (LINQ TO Objects) 第三节
- What's New in MoSync SDK 3.0
- Discuss some new features in WCF 4.0
- 【翻译】Data Access with LINQ to SQL (1) -- New C# and VB.NET Language Features