|
|
От: |
nikov
|
http://www.linkedin.com/in/nikov |
| Дата: | 21.09.06 06:27 | ||
| Оценка: | |||
using System;
class Base { }
class Derived : Base { }
class Foo<T> where T : Derived { }
class Program
{
static void Main()
{
Type foo = typeof(Foo<Derived>);
Type T = foo.GetGenericTypeDefinition().GetGenericArguments()[0];
Console.WriteLine(T.BaseType);
}
}Derived
|
|
От: |
nikov
|
http://www.linkedin.com/in/nikov |
| Дата: | 21.09.06 06:31 | ||
| Оценка: | 12 (2) | ||
If the current Type represents a type parameter of a generic type definition, BaseType returns the class constraint, that is, the class the type parameter must inherit. If there is no class constraint, BaseType returns System.Object.