These days I’m reading “C# in Depth, Second Edition” written by a very famous C# MVP Jon Skeet. In his book Jon cleared the difference between Parameters and Arguments which I thought to share, with his permission. A lot of software developers really use these words interchangeably when discussing about programming with each other and sometimes we never realized that.
A parameter is the variable which is part of the method or indexer declaration whereas an argument is an expression used when calling the method or indexer. For example:
private void M1(int number)
{
// some code
}
//somewhere else in the code 
int value = 10;
M1(value);

In the code snippet above number is the parameter whereas as value is the argument. Hope you will now use these words properly, if you were interchanging them previously like me 🙂

Categories: C#

5 Comments

Anum · February 4, 2010 at 11:20 am

Correct me if i am wrong :I don’t think that ‘VALUE'(the variable)is the argument.. the value the variable ‘VALUE’ holds is the argument …

Adil Mughal · February 4, 2010 at 11:50 am

@Anum: As per definition of argument the varibale ‘value’ is argument and also if I call M1 like :

M1(100) or M1(a) //where int a=5;

both 100 and ‘a’ are argument

Jon · February 4, 2010 at 11:55 am

Section 7.4.1 suggests that the argument here would be “value” (the variable). The argument is *evaluated* to 10 at execution time.

Adil Mughal · February 4, 2010 at 12:35 pm

Wow! Thanks Jon!

Anum · February 4, 2010 at 1:17 pm

Thanks 🙂

Leave a Reply

Avatar placeholder

Your email address will not be published.