Static pros and cons

I am a C ++ programmer who makes the switch to C #. I said not to use static classes. I understand that in C #, if a class has only static members, it must be static (my class has only static members) Could you explain to me what could be the problem when using static classes? When should we really use them?

thank

+3
source share
3 answers

A static class is basically the same as a non-static class, but there is one difference: a static class cannot be created.

http://msdn.microsoft.com/en-us/library/79b3xss3.aspx

Check also this link:

When to use static classes in C #

+1
source

, ( ) , .

+1

, , ( , ), , ( #).

, , , , .

, ? ?

If your class provides only static members, you can make it a static class, but only if you are sure that you do not need instances of this class. In fact, there is absolutely no problem using static classes, just create thread safety (if required) and make sure that it fits into your system design.

+1
source

All Articles