54powerman

          開源~節流

          C#集合類使用范例

          //Dictionary
          System.Collections.DictionaryEntry dic=new System.Collections.DictionaryEntry("key1","value1");

          //ArrayList
          System.Collections.ArrayList list=new System.Collections.ArrayList();
          list.Add(1);
          list.Add(2);
          for(int i=0;i<list.Count;i++)
          {
          ?System.Console.WriteLine(list[i]);
          }

          //HashTable
          System.Collections.Hashtable table=new System.Collections.Hashtable();
          table.Add("table1",1);
          table.Add("table2",2);
          System.Collections.IDictionaryEnumerator d=table.GetEnumerator();
          while(d.MoveNext())
          {
          ?System.Console.WriteLine(d.Entry.Key);
          }

          //Queue
          System.Collections.Queue queue=new System.Collections.Queue();
          queue.Enqueue(1);
          queue.Enqueue(2);

          System.Console.WriteLine(queue.Peek());
          while(queue.Count>0)
          {
          ?System.Console.WriteLine(queue.Dequeue());
          }

          //SortedList
          System.Collections.SortedList list=new System.Collections.SortedList();
          list.Add("key2",2);
          list.Add("key1",1);
          for(int i=0;i<list.Count;i++)
          {
          ?System.Console.WriteLine(list.GetKey(i));
          }

          //Stack
          System.Collections.Stack stack=new System.Collections.Stack();
          stack.Push(1);
          stack.Push(2);

          System.Console.WriteLine(stack.Peek());
          while(stack.Count>0)
          {
          ?System.Console.WriteLine(stack.Pop());
          }

          posted on 2006-10-18 15:48 54powerman 閱讀(2125) 評論(1)  編輯  收藏 所屬分類: C#

          Feedback

          # re: C#集合類使用范例 2009-04-14 15:55 w

          ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,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,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,  回復  更多評論   


          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 满城县| 洱源县| 江阴市| 江油市| 石景山区| 通江县| 泰州市| 和田县| 繁峙县| 南充市| 旬邑县| 大石桥市| 荔浦县| 浪卡子县| 巨鹿县| 汪清县| 兰溪市| 诏安县| 淄博市| 凌海市| 郎溪县| 平阳县| 晋城| 乐都县| 金川县| 徐州市| 香港 | 伊川县| 黎城县| 子洲县| 合山市| 鹤岗市| 墨竹工卡县| 始兴县| 运城市| 上栗县| 贡觉县| 广饶县| 蒙山县| 墨玉县| 营口市|