-3
static void Main(string[] args)
{
List<string> classroom = new List<string> { "Armen", "Babken", "Hayk", "Edgar", "Tatev", "Anna", "Aram", "Karo", "Baghdig", "Harut", "Ruzanna" };
foreach (string student in classroom)
{
Console.WriteLine(student);
}
List<string> shuffledClassroom = ShuffleList(classroom);
foreach (string student in shuffledClassroom)
{
Console.WriteLine(student);
}
Console.ReadLine();
}
static List<T> ShuffleList<T>(List<T> inputList)
{
List<T> randomList = new List<T>();
Random rnd = new Random();
int randomIndex = 0;
while (inputList.Count > 0)
{
randomIndex = rnd.Next(0, inputList.Count);
randomList.Add(inputList[randomIndex]);
inputList.RemoveAt(randomIndex);
}
return randomList;
}