You could roll your own using the yield keyword. Here's something that'll give you similar functionality. You'll need to include this namespace to make use of the IEnumerable interface:
using System.Collections;
Here's an example:
public static void Main()
{
string[] myColors = { "red", "green", "blue" };
// this would be your external loop, such as the one building up the table in the RoR example
for (int index = 0; index < 3; index++)
{
foreach (string color in Cycle(myColors))
{
Console.WriteLine("Current color: {0}", color);
}
}
}
public static IEnumerable Cycle<T>(T[] items)
{
foreach (T item in items)
{
yield return item;
}
}
The Cycle method uses generics in the code sample above to allow the use of other types. For example, where myColors is declared you could use:
int[] myInts = { 0, 1, 2, 3 };
bool[] myBools = { true, false };
And in the loop you could have:
foreach (int i in Cycle(myInts))
{
Console.WriteLine("Current int: {0}", i);
}
foreach (bool b in Cycle(myBools))
{
Console.WriteLine("Current bool: {0}", b);
}