Morten Wennevik <Mo************@hotmail.com> wrote:
Why do you want to cast it to object?
Foo(ref mc1);
should work just fine as it derives from object
Foo(ref (object)mc1);
should work too, but is unecessary.
No, neither work.
From the spec:
<quote>
When a formal parameter is a reference parameter, the corresponding
argument in a method invocation must consist of the keyword ref
followed by a variable-reference (§12.3.3) of the same type as the
formal parameter
</quote>
Compare that with:
<quote>
When a formal parameter is a value parameter, the corresponding
argument in a method invocation must be an expression of a type that is
implicitly convertible (§13.1) to the formal parameter type.
</quote>
--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too