This is not an exhaustive list, but these are some of my favorite new C # 3.0 features:
Initializers of a new type. Instead of this:
Person person = new Person();
person.Name = "John Smith";
I can say the following:
Person person = new Person() { Name = "John Smith" };
Similarly, instead of adding individual elements, I can initialize types that implement IEnumerable as follows:
List<string> list = new List<string> { "foo", "bar" };
- . , :
people.Where(delegate(person) { return person.Age >= 21;);
:
people.Where(person => person.Age >= 21 );
:
public static class StringUtilities
{
public static string Pluralize(this word)
{
...
}
}
- :
string word = "person";
word.Pluralize();
. . , " ", :
var book = new { Title: "...", Cost: "..." };