Tutorial by Examples

Consider this simple class: class SmsUtil { public bool SendMessage(string from, string to, string message, int retryCount, object attachment) { // Some code } } Before C# 3.0 it was: var result = SmsUtil.SendMessage("Mehran", "Maryam", "Hello...
You can combine named arguments with optional parameters. Let see this method: public sealed class SmsUtil { public static bool SendMessage(string from, string to, string message, int retryCount = 5, object attachment = null) { // Some code } } When you want to call t...
You can place named arguments in any order you want. Sample Method: public static string Sample(string left, string right) { return string.Join("-",left,right); } Call Sample: Console.WriteLine (Sample(left:"A",right:"B")); Console.WriteLine (Sample(right...
Always use Named Arguments to optional parameters, to avoid potential bugs when the method is modified. class Employee { public string Name { get; private set; } public string Title { get; set; } public Employee(string name = "<No Name>", string title = "&lt...

Page 1 of 1