Optional Parameters: Function containing default values in its declration which can be called with less number of parameters.
e.g.
public static string CheckTicket( bool _isVIP=false,string name="Unknown")
{
//Body of function..}//Above Function can be called like..
}
1. Program.CheckTicket();
2. Program.CheckTicket(true);
3. Program.CheckTicket(true,"Bimlesh");
Named Parameters: while calling function this provides an option for passing function parameters with any sequence.
e.g.
public static string CheckTicket( bool _isVIP=false,string name="Unknown")
e.g.
public static string CheckTicket( bool _isVIP=false,string name="Unknown")
//Body of function..}//Above Function can be called like..
}
1. Program.CheckTicket();
2. Program.CheckTicket(true);
3. Program.CheckTicket(true,"Bimlesh");
Named Parameters: while calling function this provides an option for passing function parameters with any sequence.
e.g.
public static string CheckTicket( bool _isVIP=false,string name="Unknown")
{//Body of function..
}
//Above Function can be called like..
1. Program.CheckTicket(name: "Bimlesh",_isVIP:true);
2. Program.CheckTicket(name:"Bimlesh");
Sample Code
No comments:
Post a Comment