C # template type inheritance

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

public class Foo<T>

where T must inherit from a known class.

I can not find the syntax for this.

Thanks, Malki.

+3
source share
1 answer

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

public class Foo<T> where T : KnownClass
{

}
+14
source

Source: https://habr.com/ru/post/1741566/


All Articles