代码如下:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp3_foreach打印数组元素
{
class Program
{
static void Main(string[] args)
{
int[,] array = { { 1, 3, 5, 7 }, { 2, 4, 6, 8 } };
foreach (int elements in array)
Console.Write("{0} ",elements);
}
}
}
结果如图所示: