我有一个枚举,我正在调用枚举中的方法。这在java中运行良好,但我能够在c#中隐藏它#
public enum RomanConverter {
a("a",1),
b("b",5),
c("c",10),
private String name;
private int value;
public String getName() {
return name;
}
//here i am setting the value
public void setName(String name) {
this.name = name;
}
public int getValue() {
return value;
}
public void setValue(int value) {
this.value = value;
}
RomanConverter(String name, int value){
this.name = name;
this.value = value;
}
// here is am getting the value
public static int getValueByRoman(String roman){
switch(roman){
case "a":
return RomanConverter.a.getValue();
case "b":
return RomanConverter.b.getValue();
case "c":
return RomanConverter.c.getValue();
default:
return 0;
}
}
}
我想在c#中转换此代码。我使用[Descprtion]属性设置密钥,然后将值赋给值。但它给了我错误 “预期的类,委托,枚举,接口或结构”