哪个集合不实现IEnumerable

时间:2016-05-10 09:48:21

标签: c# .net collections ienumerable

using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Runtime.InteropServices.WindowsRuntime; using Windows.Foundation; using Windows.Foundation.Collections; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Controls.Primitives; using Windows.UI.Xaml.Data; using Windows.UI.Xaml.Input; using Windows.UI.Xaml.Media; using Windows.UI.Xaml.Navigation; using Windows.Devices.Geolocation; namespace Project { /// <summary> /// An empty page that can be used on its own or navigated to within a Frame. /// </summary> public sealed partial class Geolocation : Page { public Geolocation() { this.InitializeComponent(); } public async void GetCords() { Geolocator locator = new Geolocator(); Geoposition pos = await locator.GetGeopositionAsync(); await new Windows.UI.Popups.MessageDialog(pos.CivicAddress.City).ShowAsync(); } } } 下的任何类型的集合是否都不会继承System.CollectionsIEnumerable

我需要一个例子。

1 个答案:

答案 0 :(得分:4)

System.Collections中没有类直接将实现IEnumerable<T> - 该命名空间早于.NET中的泛型 - 但是可以大致定义的类&#34;集合&#34 ;在该命名空间中,所有实现IEnumerable

  • 的ArrayList
  • BitArray
  • CollectionBase的
  • DictionaryBase
  • 哈希表
  • 队列
  • ReadOnlyCollectionBase
  • 排序列表
  • 堆栈

如果我们扩展到&#34; System.Collections&#34;以下的任何命名空间我们进入System.Collections.GenericSystem.Collections.ObjectModel以及System.Collections.Specialized - 其中的所有集合类都实现了IEnumerableIEnumerable<T>或两者。