My Software Notes

Useful things I discover

Argument and Parameter

leave a comment »

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.

Example:

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“.

Advertisements

Written by gsdwriter

May 22, 2009 at 4:43 pm

Posted in Languages

Tagged with , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: