Named Arguments can make your code more C# with Example



Named Arguments can make your code more C# with Example

clear 
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); 
 

Arguments 

0 Comment's

Comment Form

Submit Comment