【发布时间】:2013-06-05 08:01:02
【问题描述】:
我有一个静态类中的静态变量列表。
namespace Test
{
public static class Numbers
{
public static readonly int One = 1;
public static readonly int Five = 5;
public static readonly int Ten = 10;
public static readonly int Eleven = 11;
public static readonly int Fifteen= 15;
}
}
我想在类中随机选择一个变量。我怎样才能做到这一点?
int randomVariable = SomeFunction(Numbers);
【问题讨论】:
-
@makc:
Numbers类来自第三方 dll -
@RameshDurai 这并不妨碍您将其所有静态变量复制到您自己的数组中。
-
对于您的示例,这是微不足道的,因此我想还有更多。您是否提前知道课程类型,例如您的示例?
-
@MatthewWatson:是的。我提前知道班级类型..