【发布时间】:2020-12-03 16:31:33
【问题描述】:
我有一段需要用 C# 翻译的 Java 代码,但在转换以下函数时遇到问题。
问题是如何转换 Class> 类型以及如何在 C# 代码中使用它。剩下的就是从 Java HashMap 到 C# Dictionary 的非常简单的转换
public final static String NULL_RULE= "NoRule";
public HashMap<String, Class<?>> getRulers() {
HashMap<String, Class<?>> ruler= new HashMap<String, Class<?>>();
ruler.put(NULL_RULE, NullRule.class);
// Other ruler.put() instructions here, with different rules implementations
// all implementing the same RuleExecutor interface
return ruler;
}
【问题讨论】:
-
Dictionary<string, Type>和NullRule.class是typeof(NullRule)
标签: java c# class syntax migration