You can't; there is no such thing as class1 nor class2; only class1<T> and
class2<T>
You could use, for instance class3<T>, and then
class3<class1<NonGenericClass>>
or
class3<class2<SomethingInheritedFromNonGenericClass>>
however, you cannot have a condition in the form you have expressed, as it
would make no sense as the condition could not possibly be evaluated in any
way at compile time. You could perhaps use some kind of interface, but
without concrete, meaningful examples of what you are trying to do it is
very hard to answer. By concrete, I mean something like below - annd *even
then* I'm not sure why I would want to do this... what you are trying to
achieve is probably more important than how you are trying to do it, as I
suspect there is a better way...
Marc
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
abstract class Animal {}
class Dog : Animal {}
class AnimalCollection<T> : Collection<T> where T : Animal {}
class AnimalList<T> : List<T> where T : Animal {}
class AnimalWalker<TAnimalType, TCollectionType>
where TCollectionType : IEnumerable<TAnimalType>
where TAnimalType : Animal{ }
class Program {
static void Main()
{
AnimalWalker<Dog, AnimalList<Dog>> dogWalker = new
AnimalWalker<Dog,AnimalList<Dog>>();
AnimalWalker<Animal, AnimalCollection<Animal>> petWalker = new
AnimalWalker<Animal, AnimalCollection<Animal>>();
}
}