Tag: ref parameters

为什么'ref'和'out'支持多态?

采取以下措施: class A {} class B : A {} class C { C() { var b = new B(); Foo(b); Foo2(ref b); // <= compile-time error: // "The 'ref' argument doesn't match the parameter type" } void Foo(A a) {} void Foo2(ref A a) {} } 为什么会发生上述编译时错误? 这与ref和out参数一起发生。