What's new in Visual Studio 2008 vs 2005 or C # 3.0 vs C # 2.0?

I looked through the Hidden Features of C # question and thought I would try one of the functions that I am not familiar with. Unfortunately, I am using Visual Studio 2005, and this feature was introduced later. Is there a good list for new features in C # 3.0 (Visual Studio 2008) and C # 2.0 (Visual Studio 2005)?

+3
source share
5 answers

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(); // Returns "people"

. . , " ", :

var book = new { Title: "...", Cost: "..." };
+6

, :

  • VS 2008 .NET, 2.0, 3.0 3.5

  • .

:

public int Id { get; set; }

:

private int _id;
public int Id {
    get { return _id; }
    set { _id = value; }
}
+2

. .NET 2 → .NET 3.5 IDE.

+2

One of the unknown but powerful features of Visual Studio 2008 is T4 (Text Template Conversion Tool) . T4 is a code generator built right into Visual Studio 2008.

Mark Scott Guthrie's blog post on Visual Studio 2008 and .NET 3.5 released . This entry was written during the release of Visual Studio 2008 and .NET 3.5. This post includes many links for new features in Visual Studio 2008 and C # 3.0.

0
source

Source: https://habr.com/ru/post/1698908/


All Articles