动态改变枚举在C#中的价值? [英] Dynamically change the Value of enum in C#?

查看:480
本文介绍了动态改变枚举在C#中的价值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个枚举

    public enum TestType:int
   {
      Aphasia = 2,
      FocusedAphasia = 5
   }

设定值。我想从5枚举'FocusedAphasia的值更改为10。谁能帮我在运行时更改枚举值

with values set. I want to change the value of the enum 'FocusedAphasia' from 5 to 10. Can anyone help me in changing the value of enum at runtime

推荐答案

您不能在运行时改变枚举。我不知道为什么你会永远需要,但在任何情况下,这是不可能的。使用一个变量将是替代品。

You cannot change enums at runtime. I'm not sure why you'd ever need to, but in any case it's not possible. Using a variable would be the alternative.

这篇关于动态改变枚举在C#中的价值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆