Skip to content
Discussion options

You must be logged in to vote

Note that static fields in a generic class are seperate for every generic instantiation.

public class Class<T>
{
    public static int P { get; set; }
}

...

Class<int>.P = 1;
Class<string>.P = 2;
Console.WriteLine(Class<int>.P); //writes 1
Console.WriteLine(Class<string>.P); //writes 2

Replies: 4 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by YairHalberstadt
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants
Converted from issue

This discussion was converted from issue #2912 on November 09, 2020 09:56.