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

9.2.5.1 Value Parameters | 9.2.5.2 Reference Parameters | 9.2.5.3 Optional Parameters | 9.2.5.4 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)

Show:
© 2015 Microsoft