why we can't create object for static class

Posted by Sanmukhait.Btech under C# on 4/19/2012 | Points: 10 | Views : 7402 | Status : [Member] | Replies : 7
why we can't create object for static class

sanmukh


Responses

Posted by: Leila on: 4/19/2012 [Member] Starter | Points: 25

Up
1
Down
Static classes can't be initiated. If you want an object of a class, you can define the class with no static and leave the methods or properties you want as static

Thanks,
Leila

Sanmukhait.Btech, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sunny4989 on: 4/19/2012 [Member] Starter | Points: 25

Up
0
Down
Because there is no instance variable, you access the members of a static class by using the class name itself.

------------------------------------------------
Learn throughout life

Sanmukhait.Btech, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sunny4989 on: 4/19/2012 [Member] Starter | Points: 25

Up
0
Down
Use of a static class is to contain methods that are not associated with a particular object...

------------------------------------------------
Learn throughout life

Sanmukhait.Btech, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sanmukhait.Btech on: 4/19/2012 [Member] Starter | Points: 25

Up
0
Down
you guys are telling me use of static keyword but that is not a answer of my question.
why we can't create object for static class.

sanmukh

Sanmukhait.Btech, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sagarsamal on: 4/12/2018 [Member] Starter | Points: 25

Up
0
Down
Static classes cannot be instatiated because a static class has a private static constructor which prevents it to be instantiated

Sanmukhait.Btech, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Jatinrawal777 on: 4/14/2018 [Member] Starter | Points: 25

Up
0
Down
Laila you are right

Sanmukhait.Btech, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Whanifeceas on: 3/15/2019 [Member] Starter | Points: 25

Up
0
Down
Reliable content Cheers.

Developer at AppLatide.com

Sanmukhait.Btech, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response