1、準備
struct Str
{
public int i;
}
class Cla
2、指派
Str str = new Str();
str.i = 10;
Cla cla = new Cla();
cla.i = 10;
分類:
運算A
static void F(Str str)
{
str.i = 100;
}
static void F(Cla cla)
cla.i = 100;
結果A
F(str);
Console.WriteLine(str.i);//結果10
F(cla);
Console.WriteLine( cla.i);//結果100
運算B
static void F(ref Str str)
static void F(ref Cla cla)
結果B
F(ref str);
Console.WriteLine(str.i);//結果100
F(ref cla);
運算C
str=new Str();
cla=new Cla();
結果C
Console.WriteLine( cla.i);//結果10
運算D
結果D
本文轉自桂素偉51CTO部落格,原文連結: http://blog.51cto.com/axzxs/810492,如需轉載請自行聯系原作者