您的位置:首页 > 编程语言 > C#

C#下ref和out关键字使用

2012-03-23 15:55 155 查看
首先先看下边的程序

class Program
{
static void Main(string[] args)
{

int t1 = 100;
Test1(ref t1);
Console.WriteLine(t1);
int t2;
Test2(out t2);
Console.WriteLine(t2);
Console.ReadLine();
}
public static void Test1(ref int t)
{
Console.Write(t);
t = 200;
Console.WriteLine(t);
}

public static void Test2(out int t)
{
t = 100;
}

}


返回值

依次为

100

200

200

100

有问题的欢迎和我联系 我觉得这个例子就很具体了 pridescc@126.com
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: