Essential C# Named Arguments  Suggest an edit

Named arguments and optional paramaters

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 this method without set retryCount argument :

var result = SmsUtil.SendMessage(
                            from       : "Cihan",
                            to         : "Yakar",
                            message    : "Hello there!",
                            attachment : new object());

Table Of Contents
22 Enum
25 GUID
49 Named Arguments
107 Stream
108 Timers
  ↑ ↓ to navigate     ↵ to select     Esc to close