What's the benefit of .Cast over .Select?

后端 未结 2 1923
粉色の甜心
粉色の甜心 2020-12-09 01:28

I have a type with implicit conversion operators to most base types and tried to use .Cast() on a collection of this type, which failed. As I dug

2条回答
  •  天命终不由人
    2020-12-09 01:56

    I checked the MSDN page for Cast, and it is an extension method to types that implement (the non-generic) IEnumerable interface.

    It can convert a collection class (such as ArrayList) which doesn't implement IEnumerable to one that does, allowing the richer operations (such as Select) to be performed against it.

提交回复
热议问题