![]() |
1
248
|
![]() |
2
55
Use Enum.GetValues to retrieve an array of all values. Then select a random array item.
测试:
-gt;
Updated: This answer originally used
|
![]() |
3
2
呼叫
|
![]() |
4
2
Here is a generic function for it. Keep the RNG creation outside the high frequency code.
使用实例:
|
![]() |
5
2
You could just do this:
No need to store arrays |
![]() |
6
1
就我个人而言,我非常喜欢扩展方法,所以我会使用类似的方法(虽然不是真正的扩展,但看起来很相似):
|
![]() |
7
1
Here's an alternative version as an
|