C# 中的資料結構

基礎篇

C# 簡介

開發環境

變數與運算

流程控制

陣列

函數

物件

例外處理

函式庫篇

檔案處理

資料結構

正規表達式

Thread

應用篇

視窗程式

媒體影音

網路程式

遊戲程式

手機程式

資料庫

雲端運算

特殊功能

委派

擴展方法

序列化

LinQ

WPF

網路資源

教學影片

投影片

教學文章

軟體下載

考題解答

101習題

一般型別 泛型型別 說明
ArrayList List< > 串列,以陣列實作的串列結構
Queue Queue< > 佇列,先進先出的結構
Stack Stack< > 堆疊,後進先出的結構
Hashtable Dictionary< > 雜湊表格,快速用 key 查找 value
StoredList StoredList< > 排序串列,使用排序與二分搜尋法的結構
ListDictionary Dictionary< > 字典,快速用 key 查找 value
HybridDictionary Dictionary< > 小集合採用 ListDictionary,集合變大時,會自動改用 Hashtable 的一種字典
OrderedDictionary Dictionary< > 比SortedList類別多了一些功能的類別
SortedDictionary StoredDictionary< > 鍵值一定是字串,用法跟 Hashtable 相似
NameValueCollection Dictionary< > NameValueCollection可以單一索引鍵對應多重值
DictionaryEntry KeyValPair< > 字典中的一個項目,(Key, Value) 的結構
StringCollection List<String> 用法跟ArrayList相似
StringDictionary Dictionary<String> 字串字典

上層結構

  1. Collection

容器物件

  1. Array
  2. ArrayList
  3. HashTable
  4. SortedList

位元容器

  1. BitArray
  2. BitVector32

泛型容器

  1. NameValueCollection
  2. Dictionary

範例:

using System;
using System.Collections;
using System.Collections.Generic;
namespace ConsoleApplication1
{
 class Program
 {
 static void Main(string[] args)
 {
 ArrayList a = new ArrayList();
 a.Add("John");
 a.Add(1);
 a.Add(3.1416);
 a.RemoveAt(2);
 Object[] array = a.ToArray();
 Console.WriteLine(array);
 List<Object> list = new List<Object>();
 list.Add("John");
 list.Add("Mary");
 list.Add("George");
 list.Add("3.14159");
 list.Add(3.14159);
 foreach (Object o in list)
 Console.Write(o+" ");
 Console.WriteLine();
 char c = 'A';
// Console.Write("{0:X}", (int) c);
 Hashtable h = new Hashtable();
 h.Add("John", "0977332415");
 h.Add("Mary", "0977342415");
 h.Add("George", "0977372416");
 h.Add("Peter", "0977332425");
 String gtel = (String) h["George"];
 Console.WriteLine("George Tel : "+gtel);
 Dictionary<String, String> d = new Dictionary<string, string>();
 d.Add("John", "0977332415");
 d.Add("Mary", "0977342415");
 d.Add("George", "0977372416");
 d.Add("Peter", "0977332425");
 gtel = d["George"];
 Console.WriteLine("George Tel : " + gtel);
 }
 }
}

Post preview:

(will not be published)


本網頁的作者、授權與引用方式

作者
陳鍾誠,於金門大學資訊工程系,電子郵件:wt.ude.uqn|ccc#wt.ude.uqn|ccc,網站:http://ccckmit.wikidot.com
授權
本文採用創作共用 (Creative Common) 3.0 版的 姓名標示─非商業性─相同方式分享 授權條款,歡迎轉載或修改使用,但若做為商業使用時必須取得授權,引用本文時請參考下列格式。
中文版 (APA格式)
陳鍾誠 (10 Jun 2010 01:25),(網頁標題) C# 中的資料結構,(網站標題) 免費電子書:C# 程式設計,10 Jun 2010 01:25,取自 http://cs0.wikidot.com/datastructure ,網頁修改第 14 版。
英文版 (APA格式)
Chung-Chen Chen (10 Jun 2010 01:25), Retrieved 10 Jun 2010 01:25 from http://cs0.wikidot.com/datastructure, Page Revision 14.
page revision: 14, last edited: 01 Aug 2019 02:43
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License
Click here to edit contents of this page.
Click here to toggle editing of individual sections of the page (if possible). Watch headings for an "edit" link when available.
Append content without editing the whole page source.
Check out how this page has evolved in the past.
If you want to discuss contents of this page - this is the easiest way to do it.
View and manage file attachments for this page.
A few useful tools to manage this Site.
Change the name (also URL address, possibly the category) of the page.
View wiki source for this page without editing.
View/set parent page (used for creating breadcrumbs and structured layout).
Notify administrators if there is objectionable content in this page.
Something does not work as expected? Find out what you can do.
General Wikidot.com documentation and help section.
Wikidot.com Terms of Service - what you can, what you should not etc.
Wikidot.com Privacy Policy.

AltStyle によって変換されたページ (->オリジナル) /