I do have a class, which is defined as:
public abstract class Singleton <T> : BaseObject
where T : Singleton <T>
{
}
I want to define an array of those generic singletons somewhere else. Something like
public MonoSingleton[] singletons;
How can I retrieve the proper type of that generic (that seems to be recursive, as you may see)? How can I write this out?
Are you trying to do the ‘curiously recursive template pattern’, like this?
To instantiate the derived from the base, you just use:
Since T is actually the derived type (
MyClass) and curiously is also type (CuriouslyRecursive<MyClass>).Specifically applied to your problem:
More info:
http://en.wikipedia.org/wiki/Curiously_recurring_template_pattern