I have a doubt regarding Memory Management in Variables declaration.
In my class i have around 20 methods, i am using around 50 variables through out my class.
I declared all variables globally at the starting of a class.
Is it the right way of doing? or else which one is better... Using structure or any thing else???
Below am showing a basic example, i need to use optimize my memory.
class Program
{
static int a, b, c, d; //----> Here am declaring , i need any other way
static void Main(string[] args)
{
a = 10;
b = 20;
c = 30;
d = 40;
int result = add(a, b, c, d);
Console.WriteLine(result);
Console.ReadLine();
}
public static int add(int w, int x, int y, int z)
{
return w + x + y + z;
}
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…