我如何迭代多维数组的行和列? [英] How do I iterate rows and columns of a multidimensional array?

查看:115
本文介绍了我如何迭代多维数组的行和列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想单独迭代的二维阵列的行和列:

I would like to iterate the rows and columns separately on a two dimensional array:

object[,] values;

我将如何通过公正行,只是列迭代?

How would I iterate through just the rows and just the columns?

推荐答案

那要看什么是列和行给你,但你可以用code这个片断:

It depends what's columns and rows for you but you could use this snippet of code:

for (int i = 0; i < values.GetLength(0); i++)
            Console.WriteLine(values[i, 0]);

for (int i = 0; i < values.GetLength(1); i++)
            Console.WriteLine(values[0, i]);

这篇关于我如何迭代多维数组的行和列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆