C#中for循环的变种有以下几种:
foreach (var item in collection)
{
// do something
}
for (int i = collection.Length - 1; i >= 0; i--)
{
// do something
}
for (int i = 0; i < rows; i++)
{
for (int j = 0; j < columns; j++)
{
// do something
}
}
foreach (var (item, index) in collection.WithIndex())
{
// do something
}
while (condition)
{
// do something
}
do
{
// do something
} while (condition);