In the first invocation, the variable x
is passed by value, as it's just an array. In the second invocation, a new array
of ints is created containing the two values specified, and a reference to
this array is passed.
Mini-glossary
Some informal definitions and summaries
of terms:
Function member : A
function member is a method, property, event, indexer, user-defined operator,
instance constructor, static constructor, or destructor.
Output parameter A
parameter very similar to a reference parameter, but with different definite
assignment rules.
Reference parameter (pass-by-reference
semantics) A
parameter which shares the storage location of the variable used in the function
member invocation. As they share the same storage location, they always have
the same value (so changing the parameter value changes the invocation variable
value).
Reference type Type
where the value of a variable/expression of that type is a reference to an
object rather than the object itself.
Storage location A
portion of memory holding the value of a variable.
Value
parameter (the default semantics, which are pass-by-value) A value
parameter that has its own storage location, and thus its own value. The initial
value is the value of the expression used in the function member
invocation.
Value
type Type
where the value of a variable/expression of that type is the object data
itself.
|