Is it possible to have different value of static variable for every instance?

I have a class with some static variables and I want to create multiple independent instances of this class. Independent meaning, that they do not share values of these static variables.

Is there a way how to achieve this without refactoring said class?

Jon Skeet
people
quotationmark

I have a class with some static variables and I want to create multiple independent instances of this class.

In that case you just don't want static variables. static means "associated with the type rather than an instance of the type" - you just want instance variables.

That may mean changes elsewhere in your app, of course, but there's nothing you can do about that - or at least, any alternatives are going to be much more hacky than just taking the straightforward approach.

people

See more on this question at Stackoverflow