我有一个接受hashTable的方法,我使用concat将它添加到另一个hashTable的末尾,但是我收到此错误:
The type arguments for method
System.Linq.Enumerable.Concat<TSource>(this System.Collections.Generic.IEnumerable<TSource>,System.Collections.Generic.IEnumerable<TSource>)'
cannot be inferred from the usage.
我不完全明白这意味着什么或我错了什么.我的方法看起来像这样:
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
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。