Trying to randomize enum values. Problem is the enumerations are in a references file that I refer to in my code. For example
public enum AccountTypeEnum
{
Direct,
Partner,
Referral,
Resold,
}
is in my reference file and in my code I need to refer to AccountTypeEnum and randomize it so when I run my program I can get one of those 4 values.
What I have so far that I believe randomizes the values is this:
public void AcctType()
{
string[] Types = Enum.GetNames(typeof(AccountTypeEnum));
Random randType = new Random();
int randomenum = randType.Next(Types.Length);
var ret = Enum.Parse(typeof(AccountTypeEnum), Types[randomenum]);
}
Any suggestions on what I’m doing wrong?
Figured it out. created a new class:
And when referencing the enum value I refered to the class like this:
Worked great!