如何搭配INT来枚举 [英] How to match int to enum
本文介绍了如何搭配INT来枚举的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我收到返回值长的形式,或从本机code在Android中,这是我想转换或搭配枚举,处理的目的诠释。可能吗 ? 怎么样?
I am receiving return value in the form of long or int from Native code in Android, which I want to convert or match with enum, for processing purpose. Is it possible ? How?
推荐答案
如果你有充分的控制值和枚举的,而且他们的顺序,您可以使用枚举序号值:
If you have full control of values and enums, and they're sequential, you can use the enum ordinal value:
enum Heyo
{
FirstVal, SecondVal
}
...later
int systemVal = [whatever];
Heyo enumVal = Heyo.values()[systemVal];
int againSystemVal = enumVal.ordinal();
这篇关于如何搭配INT来枚举的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文