Why do so many named collections in .NET not implement IEnumerable?

后端 未结 2 1110
佛祖请我去吃肉
佛祖请我去吃肉 2021-02-20 00:43

Random example:

ConfigurationElementCollection

.Net has tons of these little WhateverCollection classes that don\'t implement

2条回答
  •  悲&欢浪女
    2021-02-20 01:41

    As Adam Houldsworth said in a comment already, you simply need to use the Cast<> method.

    Example:

    var a = new DogCollection();
    var allFidos = a.Cast().Where(d => d.Name == "Fido"); 
    

提交回复
热议问题