C#, C# Parameter

Named parameter in C#


In this article I will discuss about named parameter. Now-a-days in most of the interview you will get this question.


When we are passing some parameter to methods that time we have to remember the parameter orders, because if the parameter execution order will not same as per the passed sequence, then it will cause of the error. So named parameter is the type of parameter passing type where we do not remember the sequence of the parameter. Here we just have to mention the name of the parameter, then when we will call the parameter it will find the parameter as per the name not by the order of the sequence.
Here, follow the code to know about how to implement the named parameter
 public static void NamedParameter(int i, string firstName, string lastName)
            string strResult = firstName + i + lastName;
            Console.WriteLine("Final value is: " + strResult);

static public void Main()
NamedParameter(lastName: “Mishra”, i: 2, firstName: “Bidyasagar”);

OUTPUT: Final value is: Bidyasagar2Mishra
  • In the above example, parameter sequence are not matching between calling method and called method.
  • Here, I did not find any error due to the use of the named parameter


In the above article I discussed about the named parameter in c#, I hope, you got the proper implementation of  the named parameter. Happy to helping you 😊 

About Bidyasagar Mishra

Leave a Reply

Your email address will not be published. Required fields are marked *