📜  在不同的函数 C# 代码示例中访问局部变量

📅  最后修改于: 2022-03-11 14:49:17.297000             🧑  作者: Mango

代码示例1
The closest thing that somehow relates to your question that I can think of are ref-Parameters in method calls:

void SomeMethod()
{
    int x = 1;
    SomeOtherMethod(ref x);
    // at this point x==2
}

void SomeOtherMethod(ref int a)
{
    a = 2;
}