Optional Parameters and Named Arguments in Framework 4
This time I will demonstrate another nice feature in the framework 4 C # 4.0 now supports using Optional Parameters with Methods, Constructors, and Indexers . Earlier versions of the framework, create a mountain default variable is actually needs to create two methods. private static double GetPriceIncludesVAT( double p, double vat) { return p * vat; } private static double GetPriceIncludesVAT( double p) { return GetPriceIncludesVAT(p, 16.5); } Today, with the framework 4, C #, we can give a default (like VB) to methods. Another nice thing we got, it Named Arguments . So that the code will organized - we can be the names in a methods call. Look for the following example: double priceWith15VAT = GetPriceIncludesVAT(vat: 15, p: 50); Here is the Code: using System; namespace OptionalParm { class Program ...