Following the path to bring together their 2 main .NET programming languages, Microsoft has introduced several language enhancements to C# in their just released version 4.0 Some of these features have been available for VB (.NET) for quite a while but now add comfort and transparency also to C# based .NET code. The first language enhancement is optional arguments: You can now define method arguments that can be omitted when calling that method. Additionally you can supply default values for such optional arguments. Imagine a simple sample where you need a function to save a picture blob. You might want to specify the filetype and also an optional percent base scaling.
You can now call this method in the following ways: Another very useful addition to C# 4.0 are named arguments. Consider the following method that also includes optional arguments: When calling that method you can directly assign arguments by their name: Using named arguments can greatly improve readability and transparency especially with long lists of arguments. With optional arguments you can simplify your method declarations. Visual Studio 2010 fully supports both named and optional arguments with the build in IntelliSense:
Now try to do this with Team Developer...