Which of these two is the correct term: Named Parameters or Named Arguments?

As for C # 4.0, which of these two is the correct term: Named Parameters or Named Arguments? I find many cases of both terms, so I'm rather confused how to mention them (say, in the official documentation)?

+5
source share
4 answers
Parameters

have always been named; in the context of providing values ​​for a method, they are arguments — however, then the name you specify is the name of the parameter. Therefore, I see how this will be confused, but in the context we provide a name for the compiler to resolve the argument, so ftw is called named arguments.

More specific:

7.5.1

- , - . , .

+4

MS " " . ; , .

( - MSDN " " #.

EDIT: - . , .:)

+1

, , . , " ":

class A<T> { }

" ":

var a = new A<string>();

# 4:

, , .

:

, .

(AFAIKnew) # " " Attributes. , "named paramters". , .

, , , . , . "named parameters" : , .

// The part before the : is the named parameter,
// and the part after the : is the argument
SomeMethod(someParam: someArg);

, , . , , "named parameter" "named argument". (, 7.5.1 .)

+1

, , 7.5.1 , 7.5.1.1, :

, , .

, , .

public static void SayHello(string name = "John Doe", int age = 30)
{
  Console.WriteLine("Hello {0}, I see you're {1} years old.", name, age);
}

static void Main(string[] args)
{
  SayHello(age:42);
}

Main "name", , , ( , , , SayHello). , 42 "" ( , ). , :

SayHello (: "vFred", : 7);

, " ", - API, . , , , . , , # , , .

, , , , , , - , , , ++.

0

All Articles