Random rnd = new Random();
if((rnd.Next() & 1) == 0)
{
}
else
{
}
This works by checking if the lowest bit is not set (integer is even) but you could also check if bit is set ( == 1 which amounts to odd).
Another way to go is % (modulo operator) which gives the remainder.
x % n gives the remainder of the division of x by n: e.g X = 6 N = 3
6 % 3 == 0
This is very usefull if you need more than the 2 options "yes" and "no".
For example:
0 == "Yes"
1 == "No"
2 == "Ask again later"
3 == "Not very likely"
int numberOfChoices = 4;
Random rnd = new Random();
switch(rnd % numberOfChoices)
{
case 0:
break;
case 1:
break;
case 2:
break;
case 3:
break;
}
Cheers
Manfred