In C# what is the difference between:
public static class ClassName {}
And:
public class ClassName {}
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
A static class cannot be instantiated, and can contain only static members. Hence, the calls for a static class are as:
MyStaticClass.MyMethod(...)orMyStaticClass.MyConstant.A non static class can be instantiated and may contain non-static members (instance constructors, destructor, indexers). A non-static member of a non-static class is callable only through an object: