Can we pass default parameter values in C#?

 Posted by Ddd on 2/4/2011 | Category: C# Interview questions | Views: 3128 | Points: 40
Answer:

Yes, in C# 4.0, we are provided with the facility to pass parameters with default
values
Consider this example:
using System; 

class Program
{
public static void mymethod(string ename="dd")
{
Console.WriteLine(ename);
}
static void Main()
{
mymethod();
}
}
//Output will be dd;


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response