views:

48

answers:

2

When a class is defined as a private static, why do I need to make the get and set methods static?

A: 

Because you can't return a static member from an instance method.

Justin Niessner
That makes sense! Thank you:)
A: 

It seems redundant to have to mark all members in a static class as static but C# requires that you do this. It's just the way the compiler was implemented.

As far as I know there are no members that inherit any modifiers from the type by default. In other words, a public class's members are not all public by default, etc. By requiring that you mark each member as static you are explicitly laying out the contract of the type.

Andrew Hare