Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between arguments/parameters in C# [duplicate]

Possible Duplicate:
What's the difference between an argument and a parameter?

What is the difference between an argument & a parameter in C#?

Are they the same thing?

like image 392
Goober Avatar asked Nov 02 '09 21:11

Goober


People also ask

What is difference between parameters and arguments?

Note the difference between parameters and arguments: Function parameters are the names listed in the function's definition. Function arguments are the real values passed to the function. Parameters are initialized to the values of the arguments supplied.


1 Answers

Well, neither keyword is present in the language, so the question is somewhat vague. The best that can be done is to look how each term is used in C# language specification (1.6.6.1 "Parameters"):

Parameters are used to pass values or variable references to methods. The parameters of a method get their actual values from the arguments that are specified when the method is invoked.

So, "parameters" refer to names, and "arguments" refer to values bound to those names. E.g.:

void Foo(int x, int y); // x and y are parameters Foo(1, 2);  // 1 and 2 are arguments 
like image 82
Pavel Minaev Avatar answered Oct 09 '22 18:10

Pavel Minaev