【发布时间】:2021-11-03 02:25:16
【问题描述】:
var stringValue: String = "ort"
如何比较stringValue与Data枚举类中的nameOfCode,并从android中Kotlin中的枚举类获取对应的code值。
enum class Data(val nameOfCode: String, val code: String) {
WES("wes", "6"),
ORT("ort", "70"),
R("R", "7"),
RON("Ron", "6,7"),
LO("Lo", "6,70"),
OT("ot", "7,70"),
ALL("All", "6,7,7000")
}
例如:这里的字符串值为“ort”,因此在枚举 ort 中对应的代码值为“70”。如何获得这个值。
【问题讨论】: