function difference - “Parameter” vs “Argument”




parameters method (2)

Possible Duplicate:
Arguments or parameters?

I got parameter and argument kind of mixed up and did not really pay attention to when to use one and when to use the other.

Can you please tell me?


Answers

A parameter is the variable which is part of the method’s signature (method declaration). An argument is an expression used when calling the method.

Consider the following code:

void Foo(int i, float f)
{
    // Do things
}

void Bar()
{
    int anInt = 1;
    Foo(anInt, 2.0);
}

Here i and f are the parameters, and anInt and 2.0 are the arguments.


Or may be its even simpler to remember like this, in case of optional arguments for a method:

public void Method(string parameter = "argument") 
{

}

parameter is the parameter, its value, "argument" is the argument :)





function parameters language-agnostic arguments terminology