An optional parameter has a default value. A method with an optional parameter can be called with only some of its parameters specified. This feature introduced in.Net framework 3.5. Using this feature in new versions of the C# language, we add default values for formal parameters. If we not pass the all parameter, CLR takes the default value to optional parameter. If we pass the value, it will affect to the particular parameter.
Example:
class Program
{
static void Main(string[] args)
{
display("hai");
display("Welcome to my Sample", "hai");
Console.ReadKey();
}
public static void display(string message = "Hello World", string s)
{
Console.WriteLine(message);
}
}