| 1. |
What Is A Parameter? Explain The New Types Of Parameters Introduced In C# 4.0.? |
|
Answer» A parameter is a special kind of variable, which is used in a function to provide a piece of information or input to a caller function. These inputs are called arguments. In C#, the different types of parameters are as follows:
The example of optional parameter is as follows: public int Sum(int a, int b, int c = 0, int d = 0); /* c and d is optional */ • NAMED parameter - Refers to the new parameter introduced in C# 4.0. Now you can provide arguments by name rather than position. The example of the named parameter is as follows: public void CreateAccount(string name, string address = "unknown", int age = 0); A parameter is a special kind of variable, which is used in a function to provide a piece of information or input to a caller function. These inputs are called arguments. In C#, the different types of parameters are as follows: The example of optional parameter is as follows: public int Sum(int a, int b, int c = 0, int d = 0); /* c and d is optional */ • Named parameter - Refers to the new parameter introduced in C# 4.0. Now you can provide arguments by name rather than position. The example of the named parameter is as follows: public void CreateAccount(string name, string address = "unknown", int age = 0); |
|