Named Parameters in C# 4.0
Syntax to pass Named parameter is : parameter : value
For example , there is a method SumNumber which calculates sum of paramter a and b
public int SumNumber ( int a , int b )
{
return a+b;
}
Using named paramter , we can this method
SumNumber ( b : 5 , a : 4 );
Named paramters advantages :
What are Named Parameters in C# 4.0 ?
Named Parameters allows developers to not look at the order of parameters in method and developers can pass 1st parameter as 2nd and 2nd parameter as 1st .
Syntax to pass Named parameter is : parameter : value
For example , there is a method SumNumber which calculates sum of paramter a and b
public int SumNumber ( int a , int b )
{
return a+b;
}
Using named paramter , we can this method
SumNumber ( b : 5 , a : 4 );
Named paramters advantages :
- Increases code readability
- Developer need not remember order of paramters.
Just started working on C# 4.0. This info is very useful
ReplyDelete