Random iteration in for loop

c#, for-loop, random

Solution

Random r = new Random();
foreach (int i in Enumerable.Range(0, 9).OrderBy(x => r.Next()))
{
    Console.WriteLine(i);
}

Problem

I would like to make a for loop that loops through the numbers 0-8 in a random order. Note that every number can only be visited once. How can I achieve this?

Original source

Related problems