hi i tried a code to implement non repeating random numbers from1 to 25..but its showing only 24 numbers..code is below..pls help me..or sujjest me a good code for non repeating random numbers
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace teasting
{
class Program
{
static void Main(string[] args)
{
Random generator = new Random();
int[] j = new int[26];
for (int i = 0; i <= 25; i++)
{
j[i] = generator.Next(1, 26);
//check:
//for (int k = 1; k < i; k++)
//{
// if (j[i] == j[k]&&j[i]>25)
// {
// j[i] = generator.Next(1, 26);
// goto check;
// }
//}
//Console.WriteLine(""+j[i].ToString());
}
check:
for (int i = 0; i < 25; i++)
{
for (int k = i + 1; k < 25; k++)
{
if (j[i] == j[k])
{
j[i] = generator.Next(1, 26);
goto check;
}
}
}
for (int i = 0; i < 25; i++)
{
Console.WriteLine(j[i].ToString());
}
Console.ReadLine();
}
}
}