C Sharp Enum: Difference between revisions

From Leo's Notes
This page was last edited on 24 February 2017, at 19:12.
No edit summary
m Text replacement - "<code>" to "{{code|"
Line 1: Line 1:


== Random Enum Value ==  
== Random Enum Value ==  
Create a new <code>Random</code> object to use on the code below.
Create a new {{code|Random</code> 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]]

Revision as of 19:12, 24 February 2017

Random Enum Value

Create a new {{code|Random object to use on the code below.

Array values = Enum.GetValues(typeof(HallEvents));
return  (HallEvents) values.GetValue(this.Random.Next(values.Length));