There’s no such thing as a global variable in C#, and nor is there a modifier to make local variables retain values between invocations (there is a C# static modifier but that is for a totally different purpose).
But you can achieve what you describe with a member variable of the class:
public class ExampleClass
{
private int a = 0;
void f()
{
Debug.Log(a);
a++;
}
}