i put a random number generator together using Linq. the range of those random numbers needs to be in this case 1-6 inclusive. i want groups of 3 distinct numbers chosen.
i don't understand why this code returns groups that contain only 2 numbers.
do
{
Random rnd = new Random();
int[] myRndNos = Enumerable
.Range(1, 6)
.Select(i => rnd.Next(1, 7))
.Distinct()
.Take(3)
.ToArray();
string test = string.Join(",", myRndNos);
System.Console.WriteLine(test);
Console.ReadKey(true);
} while (true);
it returns a sample like:
4,6,1
5,2,3
2,4,5
3,2
3,5,1
etc...
why in some cases is it taking only 2 numbers? doesn't make sense to me. tx