In C#, you can declare a class as static, which requires all members to also be static. Is there any advantage (e.g. performance) to be gained by doing so? Or is it only a matter of making sure you don't accidentally declare instance members in your class?
Or is it only a matter of making sure you don't accidentally declare instance members in your class?
It's that, but it's more than that:
Basically it tells the compiler and other developers "This is never meant to be instantiated - so if it looks like you're trying to use an instance, you're doing it wrong."
I doubt that there are any performance benefits, but all the above are enough for me :)
Oh, and you can only declare extension methods in static classes too...
I guess you are close to answer, sharing the link which might answer your question. https://softwareengineering.stackexchange.com/questions/103914/why-and-when-should-i-make-a-class-static-what-is-the-purpose-of-static-key
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With