why we can't create object for static class

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

sanmukh


Responses

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: Leila on: 4/19/2012 [Member] Starter | Points: 25

Up
0
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: 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: Sakthi.Singaravel on: 4/19/2012 [Member] Silver | Points: 25

Up
0
Down
Static classes are sealed and therefore cannot be inherited and can't create Object....

Regards,
Singaravel M

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

Posted by: Sakthi.Singaravel on: 4/19/2012 [Member] Silver | Points: 25

Up
0
Down
The user has no control on when the static class is executed in the program.
We don't have control means, object not needed.
Its the reason for we can't create object for static class.

Regards,
Singaravel M

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

Login to post response