Remove static keyword from members of static classes #4248
Answered
by
Unknown6656
osamakawish
asked this question in
Q&A
-
Since all the members of a static class must be static, is there a reason why the (This sort of fits under ideas as well as Q&A equally.) |
Beta Was this translation helpful? Give feedback.
Answered by
Unknown6656
Dec 18, 2020
Replies: 1 comment 5 replies
-
Probably because adding or removing public static class MyClass
{
int i = 24;
static void M() => Console.WriteLine(i);
} removing the MyClass.i = 999;
MyClass.M(); |
Beta Was this translation helpful? Give feedback.
5 replies
Answer selected by
osamakawish
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Probably because adding or removing
static
frompublic [static] class MyClass {
would break the existing static methods.Imagine the following:
removing the
static
-keyword from the first line would break the following code (e.g. in an other class):