If I have
abstract class Base<TSub>
{
protected static List<TSub> MyStaticList;
}
class DerivedA : Base<DerivedA>
{
}
class DerivedB : Base<DerivedB>
{
}
I get two independent MyStaticList variables, one for each base class.
If instead the base looked like this
class Base<TSub>
{
protected static List<string> MyStaticList;
}
i.e., the template parameter was nowhere used, am I guaranteed to still get two independent MyStaticList variables?
(I need this for the availableValues() method of a customized Enum-like class hierarchy.)
http://blogs.msdn.com/b/gusperez/archive/2005/08/09/449363.aspx
EDIT
A very similar question was asked before Generic List and static variable behaviour in c#
You’ll have to go with a fully static construct to use inside of your generic classes. Maybe something like…