看例子
static void Main(string[] args)
{
int yp=5;
fun_name(out yp,ref yp);
Console.WriteLine(yp);
Console.ReadKey();
}
static void fun_name( out int x,ref int y)
{
x = y;
x += 5;
}
首先:ref是必须先复制,out是必须出来时候有值(系统会检查,可以不初始化out的x的值;)