我有一个接受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#来说还是新手。
答案 0 :(得分:6)
不幸的是HashTables
两个foreach (DictionaryEntry entry in hashTable)
{
if(!ht.ContainsKey(entry.Key))
{
ht.Add(entry.Key, entry.Value);
}
}
// rest of the logic
没有简单的方法,你必须以传统的方式循环每个条目。
&