C Sharp Enum: Difference between revisions
From Leo's Notes
This page was last edited on 24 February 2017, at 19:14.
No edit summary |
m Text replacement - "</code>" to "}}" |
||
| (One intermediate revision by the same user not shown) | |||
| Line 1: | Line 1: | ||
== Random Enum Value == | == Random Enum Value == | ||
Create a new | Create a new {{code|Random}} object to use on the code below. | ||
Array values = Enum.GetValues(typeof(HallEvents)); | Array values = Enum.GetValues(typeof(HallEvents)); | ||
return (HallEvents) values.GetValue(this.Random.Next(values.Length)); | return (HallEvents) values.GetValue(this.Random.Next(values.Length)); | ||
[[Category:C-Sharp]] | [[Category:C-Sharp]] | ||
Latest revision as of 19:14, 24 February 2017
Random Enum Value
Create a new Random object to use on the code below.
Array values = Enum.GetValues(typeof(HallEvents)); return (HallEvents) values.GetValue(this.Random.Next(values.Length));