public static void DoSomething()
{
int a;
string b;
//..do something
}
In the example above, i have declared two variables. Do they become static because the method that contains them is static?
public static void DoSomething()
{
int a;
string b;
//..do something
}
In the example above, i have declared two variables. Do they become static because the method that contains them is static?
You can't have local static variables.
I am positive with your opinion but in the sample code below i'am taking an access violation exception about using protected memory. Because of that maybe it isn't support static local variables but in memory management it can point same address.
No. Only the method is static but not variables.
From MSDN:
if you want to have static variable in static member, do the declaration outside the static method,
From MSDN
You can have "static" session-based variables within ASP.NET using System.Web.HttpContext.Current.Session.
Example:
No, only the method is static.
From MSDN:
And here:
As you can see, local variables are not mentioned.
You can, however use a static field:
A class can be static, and it can have static members, both functions and fields but not the variables in the static scope.