Static classes are used when a class provides functionality that is not specific to any unique instance. Here are the features of static classes in C# 2.0.
Advantages
Compiler makes sure that no instance of static class is created. In previous version of C#, the constructor has to be marked private to avoid this from happening.
Also compiler makes sure that no instance members are declared within a static class.
Sample:Public static class MyStaticClass { Private static int _staticVariable; Public static int staticVariable; { Get { Return _staticVariable; } Set { _staticVariable = value; } } Public static void Function() { } }
You need to be a premium member to use this feature. To access it, you'll have to upgrade your membership.
Become a sharper developer and jumpstart your career.
$0
$
. 00
monthly
For Basic members:
$20
For Premium members:
$45
For Elite members: