C# Language Named Arguments Named Arguments can make your code more clear

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

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 there!", 12, null);

you can make this method call even more clear with named arguments:

var result = SmsUtil.SendMessage(
    from: "Mehran",
    to:  "Maryam",
    message "Hello there!",
    retryCount: 12,
    attachment: null);


Got any C# Language Question?