Those will be considered global class levels (to distinguish from global applications). The more important difference in this case is that they are private
to the class.
Class-level globals use them, so I would definitely not call it bad practice. It is very useful to use global global clusters when you plan to expose them through property attributes . For instance:
However, I would say that it is good practice to make things local, unless otherwise required. The reason is because you have a less volatile state that belongs to an instance of the class, so there are fewer possibilities for such errors:
private int EvilMethod1() { x = (int) Math.Pow((double) y, 2); return x; } private int EvilMethod2() { y = (x + y) * 2; return y; } // Assignments depend on the current values of x and y, // as well as yielding unexpected side effects. private void PureEvil() { // Return value depends on current y; has side effect on x while assigning y. y = EvilMethod1(); // Return value depends on current x and y; has side effect on y while assigning x. x = EvilMethod2(); }
source share