#814 – Parameters vs. Arguments

A parameter is a variable name for a piece of data passed into or out of a method.    The parameter is the name by which that piece of data is referred to within the body of the method.  Parameters are listed as part of a method’s declaration, within the parentheses that follow the method’s name.

You specify a parameter by indicating the type of the parameter and its name.

        // Bark has 4 parameters
        public void Bark(int numTimes, string sound, ref int globalBarkCount, out bool didBark)

An argument is a constant or variable name passed to a method.  Each argument maps to one of the method’s parameters.

When you specify an argument, you specify the value that will be passed to the method or a variable containing the value.

            // 4 arguments passed to Bark method
            myDog.Bark(2, "Woof", ref globCount, out didBark);
Advertisements

About Sean
Software developer in the Twin Cities area, passionate about software development and sailing.

One Response to #814 – Parameters vs. Arguments

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 )

Google+ photo

You are commenting using your Google+ 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 )

w

Connecting to %s

%d bloggers like this: