你回答你的问题基本。静态变量(一个函数或者类的成员变量或局部变量)是只初始化一次,终止。例如;
So as you see although we call foo function three times the initialization of a static varible is done only once.
在创建一个类型的任何实例之前,应该初始化其中的静态成员变量。
You know that you should initialize static member variables in a type before you create any instances of that type.
当你有更复杂的逻辑来初始化静态成员变量时,请创建静态构造函数。
When you have more complicated logic to initialize static member variables, create a static constructor.
当你有更复杂的逻辑来初始化静态成员变量时,请创建静态构造函数。
When you have more complicated logic to initialize static member variables, create a static constructor.
应用推荐