What is the difference between parameter and argument?

Source: https://stackoverflow.com/questions/156767/whats-the-difference-between-an-argument-and-a-parameter

Source: https://stackoverflow.com/questions/1788923/parameter-vs-argument


A parameter is a variable in a method definition. When a method is called, the arguments are the data you pass into the method’s parameters.

public void MyMethod(string myParam) { }

...

string myArg1 = "this is my argument";
myClass.MyMethod(myArg1);

 

906

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.

 

argument is the value/variable/reference being passed in, parameter is the receiving variable used w/in the function/block.

 

Leave a Comment