假如我要做一个加法计算
int a = 1;
int b = 2;
int c = a +b;
Console.WriteLine("the result is " + c);
控制台输出:
the result is 3
在执行到第五行代码时,c就会计算a + b,可是要怎么才能让c在第五行代码之前就计算好等于3,而不是通过计算而等于3呢?
并且以后使用c这个变量而不要重新计算?
假如我要做一个加法计算
int a = 1;
int b = 2;
int c = a +b;
Console.WriteLine("the result is " + c);
控制台输出:
the result is 3
在执行到第五行代码时,c就会计算a + b,可是要怎么才能让c在第五行代码之前就计算好等于3,而不是通过计算而等于3呢?
并且以后使用c这个变量而不要重新计算?