I am testing the new optional parameters in C#. I am also testing the my new Windows Live Writer plug-in for code snippets.
// Testing optional parameters in C# 4.0
public static void DisplayMessage(string message = "NO SOUP FOR YOU")
{
Console.WriteLine("{0}: {1}", DateTime.Now, message);
}
Now this is how to execute one way or another…
static void Main(string[] args)
{
// calling with parameter
DisplayMessage("Favorite comedy line...");
// calling with named parameter
DisplayMessage(message: "Drum roll...");
// calling without parameter
DisplayMessage();
}
a5c2b31e-feca-4127-9fea-6c1c61b034a9|1|5.0