For some TreeView I want to test lots of values for the Background Property of the items.
So I have a tree that is filled with 200 items right now.
These are the possible values:
public enum EnumItemState
{
Default,
Red,
Green,
Yellow,
}
Now I wanted to quickly test different values in the view, so I wrote this code:
private EnumItemState GetRandomItemState()
{
var rand = new Random();
var val = rand.Next(0, 3);
switch (val)
{
case 0:
{
return EnumItemState.Red;
}
case 1:
{
return EnumItemState.Green;
}
case 2:
{
return EnumItemState.Yellow;
}
default:
{
return EnumItemState.Default;
}
}
}
But it is not random at all. All of the values are the same for one run.
Having breakpoints somewhere in my "Random" method, I get different, "more random" results.
What is happening here?
How to get better random results?
Is it some optimization, so all my Randoms are created with the same time seed and therefore get the same result?