Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想知道该Cast()操作是对整个IEnumerable<T>还是仅对过滤部分或它执行。
Cast()
IEnumerable<T>
Linq 操作被延迟,只有第一个元素将被强制转换然后返回。
你可以自己试试:
object[] objects = new object[] { 123, "string" }; objects.Cast<int>().First();