代码如下:

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);
        }
    }

}

结果如图所示:

c#用foreach打印二维数组中的各元素

相关文章:

  • 2021-11-24
  • 2022-12-23
  • 2022-12-23
  • 2021-12-04
  • 2021-05-31
  • 2021-11-05
  • 2021-05-21
  • 2021-11-22
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-03
相关资源
相似解决方案