[英]Using generic class as a parameter in method
Ok, I am working on a binary LoadSave system, and I just ran into a small issue. 好的,我正在使用二进制LoadSave系统,但是遇到了一个小问题。 I have a generic class that serializes a dictionary (since it isn't possible to do this in unity yet) and I am trying to use it as a parameter for a method, but I can't figure out how to do it yet. 我有一个通用类,可对字典进行序列化(因为不可能统一执行此操作),并且我正在尝试将其用作方法的参数,但我还不知道该怎么做。
My serializeable dictionary is : 我的可序列化词典是:
public class DCGSerializeableDict<TKey, TValue> : ScriptableObject where TKey: IEquatable<TKey>{}
Full code for this is HERE . 完整的代码在这里 。 (very bottom of the page) (页面底部)
and I am trying to use it as a parameter like so: 我试图像这样使用它作为参数:
private void SaveClass(DCGSerializeableDict<T,T> save,string name){}
Any suggestion on how to go about this? 关于如何解决这个问题有什么建议吗? Or is this not possible and I should find another way? 还是这不可能,我应该寻找另一种方法?
我认为您必须在方法名称后加上T:
private void SaveClass<T>(DCGSerializeableDict<T,T> save,string name){}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.