Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C# code please private void PopulateList() { for (i = 0; i <= 79; i++) shuffleNu

ID: 3572622 • Letter: C

Question

C# code please

private void PopulateList()
{
for (i = 0; i <= 79; i++)
shuffleNumbers.Add(i);
}


public List<Int32> ShuffleList<Int32>(List<Int32> inputList)
{
List<Int32> randomList = new List<Int32>();
Random r = new Random();
int randomIndex = 0;

while (inputList.Count > 0)
{
randomIndex = r.Next(0, inputList.Count);
randomList.Add(inputList[randomIndex]);
inputList.RemoveAt(randomIndex);
}
return randomList;
}

Now I need to set the shuffleNumbers List to equal what is returned by the shuffleList() method after passing the current value of shuffleNumbers to the method

Explanation / Answer

// the answer is based on the code you shared which is incomplete. I am assuming shuffleNumbers a class //variable which is List. If you have complete code, share that for most accurate answer.

// Anyways, I have shared the required code hope it helps

private void PopulateList()

{
for (i = 0; i <= 79; i++)
shuffleNumbers.Add(i);
shuffleNumbers.AddRange(ShuffleList(shuffleNumbers)); // this should work;
}

public List<Int32> ShuffleList<Int32>(List<Int32> inputList)
{
List<Int32> randomList = new List<Int32>();
Random r = new Random();
int randomIndex = 0;
while (inputList.Count > 0)
{
randomIndex = r.Next(0, inputList.Count);
randomList.Add(inputList[randomIndex]);
inputList.RemoveAt(randomIndex);
}
return randomList;
}