This is not a comprehensive list but these are some of my favorite new features of C# 3.0:
New type initializers. Instead of saying this:
Person person = new Person();
person.Name = "John Smith";
I can say this:
Person person = new Person() { Name = "John Smith" };
Similarly, instead of adding items individually, I can initialize types that implement IEnumerable like this:
List<string> list = new List<string> { "foo", "bar" };
The new syntax for lambda expressions is also nice. Instead of typing this:
people.Where(delegate(person) { return person.Age >= 21;);
I can type this:
people.Where(person => person.Age >= 21 );
You can also write extension methods to built in types:
public static class StringUtilities
{
public static string Pluralize(this word)
{
...
}
}
Which allows something like this:
string word = "person";
word.Pluralize(); // Returns "people"
And finally. Anonymous types. So you can create anonymous classes on the fly, like this:
var book = new { Title: "...", Cost: "..." };
I know of two ways to do it.
Method 1
The first method (which I prefer) is to use msbuild:
msbuild project.sln /Flags...
Method 2
You can also run:
vcexpress project.sln /build /Flags...
The vcexpress option returns immediately and does not print any output. I suppose that might be what you want for a script.
Note that DevEnv is not distributed with Visual Studio Express 2008 (I spent a lot of time trying to figure that out when I first had a similar issue).
So, the end result might be:
os.system("msbuild project.sln /p:Configuration=Debug")
You'll also want to make sure your environment variables are correct, as msbuild and vcexpress are not by default on the system path. Either start the Visual Studio build environment and run your script from there, or modify the paths in Python (with os.putenv).
Best Answer
Uusally, the only thing you need to do with .SLN files is to change the version number at the top of the file.
Your CS project files will also be almost OK, and if they're not, it's possible to tweak them so that they are OK with both 2005 and 2008.
We ran for a while with two solution files (05 and 08) sharing the same set of CS project files.
Be aware though, that you can't share VC project files between the two versions like this.
The 'tweak' for the project files is as follows:
CS Projects created on VS2008 will contain the line:
VS2005 will choke on this, and you need to change it to the following:
The latter will work with both 2005 and 2008.