Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

9.2.5 Method Parameters

Visual Studio .NET 2003

A parameter is a variable that can be used to pass information into and out of a method. Parameters of a method are declared by the method's parameter list, which consists of one or more parameters separated by commas. If no type is specified for a parameter and strict semantics are used, a compile-time error occurs. Otherwise the default type is Object or the type of the parameter's type character. Even under permissive semantics, if one parameter includes an As clause, all parameters must specify types.

Parameters are specified as value, reference, optional, or paramarray parameters by the modifiers ByVal, ByRef, Optional, and ParamArray, respectively. A parameter that does not specify ByRef or ByVal defaults to ByVal.

Parameter names are scoped to the entire body of the method and are always publicly accessible. A method invocation creates a copy, specific to that invocation, of the parameters, and the argument list of the invocation assigns values or variable references to the newly created parameters.

ParameterList ::=
   Parameter |
   ParameterList , Parameter
Parameter ::=
   [ Attributes ] ParameterModifier+ Identifier [ As TypeName ]
      [ = ConstantExpression ] 
ParameterModifier ::= ByVal | ByRef | Optional | ParamArray

See Also Value Parameters | Reference Parameters | Optional Parameters | ParamArray Parameters | 9.2.1 Regular Method Declarations | 9.2.2 External Method Declarations | 9.2.3 Overridable Methods | 9.2.4 Shared Methods | 9.1 Interface Method Implementation | 9.2.6 Event Handling | 9.2 Methods | Argument Passing ByVal and ByRef (Visual Basic Language Concepts)

© 2015 Microsoft