Generic classes and static fields

c#, generics, static

Solution

You could wrap the counter in it's own singleton class, then reference the counter class from A, B, and C.

Problem

Is there a way to share one static variable between several different generic classes ? I have a class ``` class ClassA <T> : ObservableCollection<T> { static int counter; //... } ``` and a couple of instances of it with different parameter instantiations, like ``` ClassA<int> a = new ClassA<int>(); ClassA<double> b = new ClassA<double>(); ClassA<float> c = new ClassA<float>(); ``` Is there a way that the instances a, b, and c share the static field counter ? Any answers and comments are pretty much appreciated :)

Original source