+ 2

Why do we need static class?

When i can just make all the functions & vars static? I understand we can have only one instance but what its helping with?

8th Mar 2018, 7:27 PM
Guy293
Guy293 - avatar
3 ответов
+ 3
The main reason it that is alerts the compiler when you do something non-static in this class. That you did not intended to do that. Static function are linked to the class not to the instances of the class. They usually help with simple tasks, like Count, Getinterest. Sometimes you have a whole class of them. Try make a calculator with al static Math - class. https://www.infoworld.com/article/3045882/application-development/its-all-static-static-classes-and-members-in-c.html
10th Mar 2018, 9:21 PM
sneeze
sneeze - avatar
+ 1
up
9th Mar 2018, 5:14 AM
Guy293
Guy293 - avatar
+ 1
@sneeze Good to know. Thx!
10th Mar 2018, 9:21 PM
Guy293
Guy293 - avatar