【问题标题】:Convert Java HashMap<String, Class<?>> into c#将 Java HashMap<String, Class<?>> 转换为 c#
【发布时间】: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&lt;string, Type&gt; 和 NullRule.class 是 typeof(NullRule)

标签: java c# class syntax migration


【解决方案1】:

我也在寻找 > 的最佳替代品。对于 Java 类型 Class,Selvin 的解决方案就是结果。 一些(其他)Java 到 C# 破解了存储在 https://github.com/bastie/NetVampire/blob/main/docs/DeveloperInformations.md 下的 a

【讨论】:

    猜你喜欢
    • 2019-02-03
    • 1970-01-01
    • 1970-01-01
    • 2022-11-01
    • 2013-06-17
    • 2014-09-27
    • 2017-06-17
    • 2013-02-07
    • 1970-01-01
    相关资源
    最近更新 更多