ref
public void click()
{
int a = 10, b = 10;
Debug.Log("before a:" + a + " b:" + b);
get(ref a, b);
Debug.Log("after a:" + a + " b:" + b);
}
public void get(ref int a,int b)
{
a = 20;
b = 20;
}
Output:
before a:10 b:10
after a:20 b:10
out
也是输出结果的一种 但是感觉ref是实时的(在函数未返回时就会传递)
另外ref需要初始值,out不需要