Determine if object derives from collection type

前端 未结 11 2050
时光说笑
时光说笑 2021-02-05 04:53

I want to determine if a generic object type (\"T\") method type parameter is a collection type. I would typically be sending T through as a Generic.List but it could be any co

11条回答
  •  抹茶落季
    2021-02-05 05:46

    I would test IEnumerable instead, since a collection type could implement only IEnumerable, it doesn't have to implement IEnumerable.

    It also depends: what do you mean with collection type? You could have a collection without implementing any of those interfaces.

提交回复
热议问题