除了field以外,还可以有局部变量(local var),全局变量(global var,C#不支持),静态变量(static var)。函数的参数也可看成是一种变量。
基于18个网页-相关网页
Incrementing a global variable is 2 times slow than a local var.
递增一个全局变量要比递增一个局部变量慢2倍。
Just declaring a global variable without using it in a function also slows things down (by about the same amount as incrementing a local var).
仅定义一个局部变量而没在函数中调用它,同样会减慢速度(其程度相当于递增一个局部变量)。
Storing references to global variables inside a function is a problem, as a global var inside a function seems to be nothing but a local var containing a reference to the global.
保存引用一个全局变量在函数里面是一个问题,因为一个函数变量在函数看不见但是一个局域变量包含一个引用全局。
应用推荐