what is static class in c#
A static class in C# is a class that cannot be instantiated, and can only contain static members
1. Sealed:
Static classes are sealed by default and cannot be inherited.
2. No instance members:
Static classes cannot contain instance constructors or have instance members.
3.Static members:
Static classes can only contain static members, such as methods, properties, fields, and nested types. Static members belong to the class itself, not to an instance of the class.
4. Access :
Static members can be accessed without creating an instance of the class. For example, to call a static method in a static class, you would use the class name, like MyStaticClass.StaticMethod().
No comments:
Post a Comment