宣告
System.Collections.Hashtable HT = new System.Collections.Hashtable();
資料
HT.Add(101, "CM4021-1-1-L");
HT.Add(102, "CM4021-1-1-R");
HT.Add(103, "CM4021-1-2-L");
HT.Add(104, "CM4021-1-2-R");
實做
string SLOT = "";
foreach (DictionaryEntry KK in HT)
{
if (KK.Value.ToString() == MC + "-" + L1[0] + "-" + L1[2] + "-" + L1[5].Trim())
{
SLOT = KK.Key.ToString();
}
}
排序
//Sort
ArrayList sorter = new ArrayList();
sorter.AddRange(PDLINE1.Keys);
sorter.Sort();
善用ContainKey
回覆刪除