Advertisement
Advertisement


"Parameter" vs "Argument"


Question

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?

2019/12/10
1
588
12/10/2019 6:18:30 AM

Accepted Answer

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.

2014/02/11
1005
2/11/2014 9:45:33 PM

Source: https://stackoverflow.com/questions/1788923
Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Email: [email protected]