0

I have read something's, about static classes, mostly about that static classes are "evil" in Java, and I was wondering what does the Static calss actually do?

What are the applications to it Unity C#, and C# in general?

amitklein
  • 1,302
  • 6
  • 23

1 Answers1

1

"The static modifier makes an item non-instantiable, it means the static item cannot be instantiated. If the static modifier is applied to a class then that class cannot be instantiated using the new keyword. If the static modifier is applied to a variable, method or property of class then they can be accessed without creating an object of the class, just use className.propertyName, className.methodName."

Static class basically means that there is just one instance of the object.

It can be good or bad, depends on what you need, for example if you have an int to store the player money you can use static int money and then get or set the variable from anywhere, but if you want to create something multiple time (like enemies etc') you cann't use it.

Here is a link to read more about the Static class

amitklein
  • 1,302
  • 6
  • 23