C#中的Java变量等效 [英] Java variable equivalent in C#
本文介绍了C#中的Java变量等效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
将java变量移动到c#
这个问题很简单这是java中的代码:
I have little trouble with moving java variable to c#
This is the code in java:
private final VisibleObjectController< ? extends VisibleObject > controller;
i希望在c#中做同样的事情。
< b>我尝试了什么:
i尝试
i want to do the same in c#.
What I have tried:
i tried
private VisibleObjectController< T > where T : VisibleObject controller;
但确定它不起作用,错误语法
but sure its not work, error syntax
推荐答案
您不能在私有字段(或属性)上使用约束仅限于班级或界面
You can't use a constraint on a private field (or property) only on the class or interface
public class MyCLass<t> : where T : VisibleObject
{
private VisibleObjectController<T> controller;
}
</t>
这是与如何在C#中使用相同的java扩展类? [ ^ ],你已经得到了答案。请不要重新发布;如果您有要添加的信息,请编辑原始问题。
This is the same question as How do I do the same java extends class in C#?[^], and you have already been given the answer. Please do not repost; if you have information to add then edit the original question.
这篇关于C#中的Java变量等效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文