将源代码java语言转换为C#语言
本文关键字:语言 转换 java 源代码 | 更新日期: 2023-09-27 18:25:21
我在互联网上找到了这个源代码。这个源代码是关于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;
}
}
类似的东西:Java枚举进入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