1. 程式人生 > >C# Hashtable賦值給另一個Hashtable時

C# Hashtable賦值給另一個Hashtable時

元素 全部 nbsp htable table賦值 tab tor 操作 enume

c#中想將一個hashtable的元素全部給另一個hashbale時,

使用叠代一個一個元素賦值

如:

ammus.Clear();
IDictionaryEnumerator ie = _temp.GetEnumerator();

while (ie.MoveNext())
ammus.Add(ie.Key,ie.Value);

直接變量賦值會導致其他腳本中引用原變量的操作無效,猜測只是指針地址變更。

如:

ammus = _temp;

C# Hashtable賦值給另一個Hashtable時