This website includes Education Information like a programming language, job interview question, general knowledge.mathematics

Education log

PageNavi Results No.

Ads

Friday, December 6, 2024

what is static class in c#

 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