#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