c# – 将Hashtable添加到另一个Hashtable的末尾
发布时间:2020-12-15 08:48:35 所属栏目:百科 来源:网络整理
导读:我有一个接受hashTable的方法,我使用concat将它添加到另一个hashTable的末尾,但是我收到此错误: The type arguments for method System.Linq.Enumerable.ConcatTSource(this System.Collections.Generic.IEnumerableTSource,System.Collections.Generic.IEn
我有一个接受hashTable的方法,我使用concat将它添加到另一个hashTable的末尾,但是我收到此错误:
我不完全明白这意味着什么或我错了什么.我的方法看起来像这样: 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#来说还是新手. 解决方法
不幸的是,没有简单的方法来合并/连接两个HashTable,你必须以传统的方式循环每个条目.
foreach (DictionaryEntry entry in hashTable) { if(!ht.ContainsKey(entry.Key)) { ht.Add(entry.Key,entry.Value); } } // rest of the logic (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |