0
Named arguments
Am I right to assume that when you are declaring a method’s parameters you HAVE to give each parameter a name. Thus, ALL arguments are “named arguments”.
3 Respostas
- 1
yes and also which type of data.
+ 1
Well, "Named Parameters" are a feature of C# that can match a parameter passed in, with a name. Previously parameters could only be evaluated sequentially as they were declared. Example:
public int AddNumbers(int firstNum, int secondNum). To call this method, we would need to send a first number then a second number, AddNumbers(1,2), in the order we declared them. Using the named parameter feature we can pass them in any order but, we have to tell c# which parameter we are passing eg
AddNumbers(secondNum:2, firstNum:1).
0
Thanks Kail!