Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
what is the difference between a static variable inside a static class and a static variable inside a non static class?
ex:
public static class GT { public static readonly string x; } public class GT { public static readonly string x; }
当您谈论类中的实际变量时,没有区别。静态类中的静态变量与非静态类中的静态变量相同。
另一方面..如果您谈论的是类本身,那么静态类不能包含实例变量或方法..这没有意义..因为您不能自己实例化静态类的实例。