public static int [] RandomNumbers( int ACount, int AMinValue, int AMaxValue)
{
if (ACount <= 0 ) return null ;
if (AMaxValue < AMinValue)
AMinValue = AMaxValue | (AMaxValue = AMinValue) & 0 ;
if (ACount > AMaxValue - AMinValue + 1 ) return null ; //
List < int > vValues = new List < int > ();
for ( int i = AMinValue; i <= AMaxValue; i ++ )
vValues . Add(i);
int [] Result = new int [ACount];
Random vRandom = new Random ();
for ( int i = 0 ; i < ACount; i ++ )
{
int j = vRandom . Next(vValues . Count);
Result[i] = vValues[j];
vValues . RemoveAt(j);
}
return Result;
}