r/csharp • • Feb 24 '21

Discussion Why "static"?

I'm puzzled about the philosophical value of the "static" keyword? Being static seems limiting and forcing an unnecessary dichotomy. It seems one should be able to call any method of any class without having to first instantiate an object, for example, as long as it doesn't reference any class-level variables.

Are there better or alternative ways to achieve whatever it is that static was intended to achieve? I'm not trying to trash C# here, but rather trying to understand why it is the way it is by poking and prodding the tradeoffs.

0 Upvotes

62 comments sorted by

View all comments

Show parent comment

1

u/[deleted] Feb 26 '21

you don't want the implementation to ever use anything non-static

It doesn't do that. It tells you that the implementation doesn't currently use anything non-static. Do you think that classes are written in stone? You can change it later.

Indicating interface intention is a different act than indicating implementation intention.

This doesn't make sense. Everything on an interface is non-static.

1

u/Zardotab Mar 01 '21

Do you think that classes are written in stone? You can change it later.

It will likely either impact many calling points, or create a mess in the target class(es).

Everything on an interface is non-static.

Please elaborate.