您應該使用類型安全的字典和GUID的,而不是一個泛型列表:
Dictionary<Int32, Guid> guids = new Dictionary<Int32, Guid>();
guids.Add(1, new Guid("{25892e17-80f6-415f-9c65-7395632f0223}"));
guids.Add(2, new Guid("{e33898de-6302-4756-8f0c-5f6c5218e02e}"));
guids.Add(3, new Guid("{3a768eea-cbda-4926-a82d-831cb89092aa}"));
guids.Add(4, new Guid("{cd171f7c-560d-4a62-8d65-16b87419a58c}"));
guids.Add(5, new Guid("{17084b40-08f5-4bcd-a739-c0d08c176bad}"));
List<Guid> allGuids = new List<Guid>(guids.Values);
假設你的鑰匙是一個整數,但是,這並不重要的答案。
如果你非要使用哈希表來代替:
Hashtable guids = new Hashtable();
//fill Hashtable like above
ArrayList allGuids = new ArrayList(guids.Values);
foreach (Guid guid in allGuids) {
//do something with the GUID...'
}
[所有converted從VB.Net]