//
// MyClass definition
public class MyClass
{
public int Value;
}
//
// Tester methods
public static void TestRef(ref MyClass m)
{
mValue = ;
}
public static void TestNoRef(MyClass m)
{
mValue = ;
}
public static void TestCreateRef(ref MyClass m)
{
m = new MyClass();
mValue = ;
}
public static void TestCreateNoRef(MyClass m)
{
m = new MyClass();
mValue = ;
}
public static void Main()
{
MyClass m = new MyClass();
mValue = ;
TestRef(ref m);
ConsoleWriteLine(mValue);
TestNoRef(m);
ConsoleWriteLine(mValue);
TestCreateRef(ref m);
ConsoleWriteLine(mValue);
TestCreateNoRef(m);
ConsoleWriteLine(mValue);
}
大家能马上给出正确的答案么?如果能那看来你对 ref 的用法了解得还是非常不错的其实如果大家对 C++ 比较熟悉的话把这段代码换成 C++ 的就好理解的多了
[] [] []