C# - AsEnumerable Example

前端 未结 9 1352
耶瑟儿~
耶瑟儿~ 2020-12-20 00:44

What is the exact use of AsEnumerable? Will it change non-enumerable collection to enumerable collection?.Please give me a simple example.

9条回答
  •  一生所求
    2020-12-20 00:58

    Nobody has mentioned this for some reason, but observe that something.AsEnumerable() is equivalent to (IEnumerable) something. The difference is that the cast requires the type of the elements to be specified explicitly, which is, of course, inconvenient. For me, that's the main reason to use AsEnumerable() instead of the cast.

提交回复
热议问题