将Hashtable添加到另一个Hashtable的末尾

时间:2016-04-08 03:34:31

标签: c#

我有一个接受hashTable的方法,我使用concat将它添加到另一个hashTable的末尾,但是我收到了这个错误:

  

无法从用法中推断出方法System.Linq.Enumerable.Concat<TSource>(this System.Collections.Generic.IEnumerable<TSource>, System.Collections.Generic.IEnumerable<TSource>)'的类型参数。

我不完全明白这意味着什么或我错了什么。我的方法如下:

public void resetCameras(Hashtable hashTable)
{
    Hashtable  ht = new Hashtable();

    ht.Add("time", 2.0f);
    ht.Add("easeType","easeInOutQuad");
    ht.Add("onupdate","UpdateSize");
    ht.Add("from",size);
    ht.Add("to",5.0f);

    if(hashTable != null) {
        ht = ht.Concat(hashTable);
    }

    iTween.ValueTo(gameObject,ht);
}

希望你能帮我解释一下我的错误,对C#来说还是新手。

1 个答案:

答案 0 :(得分:6)

不幸的是HashTables两个foreach (DictionaryEntry entry in hashTable) { if(!ht.ContainsKey(entry.Key)) { ht.Add(entry.Key, entry.Value); } } // rest of the logic 没有简单的方法,你必须以传统的方式循环每个条目。

&