C#中out与ref的异同
void TestOut(out int x)
{
x = 10;
}
void TestRef(ref int y)
{
y = 20;
}
void Main()
{
int a;
int b = 5;
TestOut(out a); // 此时a为10
TestRef(ref b); // 此时b为20
}
19.51KB
文件大小:
评论区