我知道这有悖于枚举的概念,但是可以在 C #/Java 中扩展枚举吗?我的意思是“扩展”,这既意味着向枚举添加新值,也意味着从现有枚举继承的 OO 意义。
I assume it's not possible in Java, as it only got them fairly recently (Java 5?). C# seems more forgiving of people that want to do crazy things, though, so I thought it might be possible some way. Presumably it could be hacked up via reflection (not that you'd every actually use that method)?
我不一定对实现任何给定的方法感兴趣,它只是激起了我的好奇心,当我想到: -)