Static field in class, how does it work
Posted on 2010-01-11
Hello Experts :)
I am a C# newbie with some Delphi background.
I am struggling to understand the idea of static field in a class.
public class Jack
public static int myField = 0;
then I can do something really strange to me...
I can assign value to a class, not even an instance of object of the class?
Jack.myField = 12;
1. How come can I use class like a variable which I do not even have to initialize?
2. How come can I change the value of ALL instances of object of the class Jacek by changing it somewhere in a code? It looks potentially very dangerous and far from a good practice of programming.
Any thoughts experts?