如果对象是泛型列表列表

由网友(狂傲与共)分享简介:有什么方法来确定一个对象是一个通用的列表?我不会知道列表的类型,我只知道这是一个列表。我该如何确定?Is there any way to determine if an object is a generic list? I'm not going to know the type of the list, I j...

有什么方法来确定一个对象是一个通用的列表?我不会知道列表的类型,我只知道这是一个列表。我该如何确定?

Is there any way to determine if an object is a generic list? I'm not going to know the type of the list, I just know it's a list. How can I determine that?

推荐答案

这将返回True

List<int> myList = new List<int>();

Console.Write(myList.GetType().IsGenericType && myList is IEnumerable);

你关心知道,如果这正是一个清单......或者,你确定它是IEnumerable的,和一般?

Do you care to know if it's exactly a "List"... or are you ok with it being IEnumerable, and Generic?

阅读全文

相关推荐

最新文章