Do variables in static methods become static automatically because they are within static scopes in c#?

后端 未结 7 962
长情又很酷
长情又很酷 2021-01-17 17:29
public static void DoSomething()
{
int a;
string b;

//..do something
}

In the example above, i have declared two variables. Do they become static

7条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-17 18:10

    From MSDN

    C# does not support static local variables (variables that are declared in method scope).

提交回复
热议问题