在C#中,可以使用typeof关键字和IsGenericType属性来判断一个类型是否是泛型类。示例如下:
using System;class Program{ static void Main() { // 判断泛型类 Type type = typeof(List<>); if (type.IsGenericType) { Console.WriteLine("此类型是一个泛型类"); } else { Console.WriteLine("此类型不是一个泛型类"); } }}在上面的示例中,我们首先使用typeof(List<>)获取List<>类型,然后使用IsGenericType属性判断这个类型是否是一个泛型类。


