This is the second version of this code I've gone through as the first version ran too quickly for the Random function to work properly. I'm trying to make sure none of the randomly generated numbers are the same and if they are replace them in the array but it's not letting me call the array. Can someone tell me what I'm doing wrong?
using System;
using System.Timers;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp4
{
class Program
{
public static Timer aTimer;
static void Main(string[] args)
{
//Create three different random integers and store them
Random rnd = new Random();
int RandA = rnd.Next(0, 26);
int RandB = rnd.Next(0, 26);
int RandC = rnd.Next(0, 26);
//Turn those three variables into an array
int[] RandArray = { RandA, RandB, RandC };
//Make sure there are no duplicates
if (RandArray[0] == RandArray[1])
{
int RandArray[0] = rnd.Next(0, 26);
}
if (RandArray[1] == RandArray[2])
{
int RandArray[1] = rnd.Next(0, 26);
}
if (RandArray[2] == RandArray[0])
{
int RandArray[2] = rnd.Next(0, 26);
}
//Print out all three values seperately
for (int i = 0; i < 3; i++)
{
Console.WriteLine("Value of: {1}", i, RandArray[i]);
continue;
}
Console.ReadKey();
}
}
}