C#中使用foreach语句遍历二维数组的源码演示


把写内容过程中比较常用的内容段备份一次,下面的资料是关于C#中使用foreach语句遍历二维数组的演示的内容。

using System;

public class w3demo{
public static void Main() {
int sum = 0;
int[,] nums = new int[3,5];

for(int i = 0; i < 3; i++)
for(int j=0; j < 5; j++)

foreach(int x in nums) {
Console.WriteLine("Value is: " + x);
sum += x;
}
Console.WriteLine("Summation: " + sum);
}
}






免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM