摘要://字符中迭代 public class ListBoxTest: IEnumerable<String> { private string[] strings; private int ctr = 0; //可枚举的类可以返回枚举 public IEnumerator<string> GetEnumerator() { foreach (string s in strings) { yield return s;//返回可枚举对象 ...
阅读全文
摘要:1.集合接口C#提供以下接口ICollection<T> 泛型集合的基接口IEnumerable<T>IEnumerator<T> 实现foreach语句枚举集合ICollection<T> 所有集合都要实现,以提供CopyTo()方法,以及Count、IsSynchronized(线程安全) SyncRoot属性IComparer<T> 比较集合中的两个对象以对集合的排序IComparable<T> IList<T> 肜于数组可索引的集合IDictionary<K,V> 用于基于<键,值&g
阅读全文
摘要:using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace QueueEx{ class Program { static void Main(string[] args) { Queue<int> iQueue = new Queue<int>();//构造一个整型集合队列 for (int i = 0; i < 10; i++) iQueue.Enqueu...
阅读全文