我在互联网上找到了这个源代码。这个源代码在java语言中,如何将这个源代码转换为c#语言。使它成为实例对象。
public enum Prioritas
{
SANGAT_RENDAH(1), RENDAH(2), SEDANG(3), TINGGI(4), SANGAT_TINGGI(5);
private int value;
private Prioritas(int value)
{
this.value = value;
}
public int getValue ()
{
return value;
}
}
答案 0 :(得分:2)
类似的东西: Java enum 进入 C#一个:
public enum Prioritas {
SANGAT_RENDAH = 1, // Technically, assignments are not necessary here and below
RENDAH = 2,
SEDANG = 3,
TINGGI = 4,
SANGAT_TINGGI = 5,
}
public static class PrioritasExtensions {
// technically you don't want it, since you can cast to int
public static int getValue(this Prioritas value) {
return (int) value;
}
}
...
Prioritas priority = Prioritas.SEDANG;
// or just cast:
// int value = (int) priority;
int value = priority.getValue(); // 3