Skip to content

Remove static keyword from members of static classes #4248

Answered by Unknown6656
osamakawish asked this question in Q&A
Discussion options

You must be logged in to vote

Probably because adding or removing static from public [static] class MyClass { would break the existing static methods.
Imagine the following:

public static class MyClass
{
    int i = 24;
    
    static void M() => Console.WriteLine(i);
}

removing the static-keyword from the first line would break the following code (e.g. in an other class):

MyClass.i = 999;
MyClass.M();

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@333fred
Comment options

@osamakawish
Comment options

@osamakawish
Comment options

@osamakawish
Comment options

@333fred
Comment options

Answer selected by osamakawish
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants