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) ...... {...}
public static bool IsAllUppercase( string s) ...... {...}
// OR
public static bool IsAllUppercase( this string s) ...... {...}
string
str;
str.IsAllUppercase();
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());
}
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 :)