Child pages
  • Static field in generic type

Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.


In the vast majority of cases, having a static field in a generic type is a sign of an error. The reason for this is that a static field in a generic type will not be shared among instances of different close constructed types. This means that for a generic class C<T> which has a static field X, the values of C<int>.X and C<string>.X have completely different, independent values.