views:

97

answers:

1

Hi,

I want to create a template class in C#, for example:

public class Foo<T>

where T must inherit from a known class.

I cant seem to find the syntax for that.

Thanks, Malki.

+12  A: 

In .NET the term generic class is used instead of template class. And what you are trying to do is called generic constraints:

public class Foo<T> where T : KnownClass
{

}
Darin Dimitrov