[C#] 枚举类型的反射调用 →→→→→进入此内容的聊天室

来自 , 2020-01-14, 写在 C#, 查看 108 次.
URL http://www.code666.cn/view/094bb65e
  1. int enumValue1 = (int)enumItem1.GetValue(enumType);
  2. int enumValue2 = (int)enumItem2.GetValue(enumType);
  3. int currentValue = (int)flagsInfo.GetValue(remoteObject, null);
  4. int newValue = currentValue | enumValue1 | enumValue2;
  5. /*
  6. 举例说明,我需要反射生成ReportViewer控件的对象实例,并且要传一个Mode值给它(Server,LocalReport)以表示是本地报表,还是取服务器报表。这种情况下,非得用反射的方式传入值。
  7. 在我的.NET通用平台中,也应用到这项技术,以反射方式创建CrystalReportViewer报表控件,再传入参数值。这种方式稍微复杂一些,但是对比它带来的灵活性,是非常值得的。
  8. */
  9. //csharp/191

回复 "枚举类型的反射调用"

这儿你可以回复上面这条便签

captcha