Argument and Parameter
There is tremendous confusion over the words “argument” and “parameter”.
Definition of argument from computeruser.com: “A value that is passed to a program, subroutine, procedure, or function by the calling program; one of the independent variables that determine the output.”
Definition of parameter from computeruser.com: “In computing, a value sent to a program or operation by the user.”
Several other sources said basically the same thing, which is that the two words are synonyms.
Well, despite the fact that most programmers I know use them to mean the same thing, they DON’T have the same meaning.
If you are going to understand the new “Named and Optional Arguments” feature in C# 4.0 (and if you’ve ever had to do Office Automation or COM Interop in C#, you will want to) then you are going to have to clear up the difference between these two terms.
Here is my attempt to clarify. I’m making it as simple as possible:
- Argument: what gets passed into a function.
- Parameter: the named slot in the signature of a function used to pass values to the function.
int howMany = CounterMethod(myTable); //example of calling a function
private int CounterMethod(DataTable table) //example of a function signature
- “myTable” in the function call is an argument.
- “table” in the function signature is a parameter.
I hope that clarifies it for you. Now you can go read all about the new C# 4.0 feature “Named and Optional Arguments“.