数组中的for循环 [英] for loop in the array

查看:58
本文介绍了数组中的for循环的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在c#中进行for循环,使我能够填充无限的数组吗?
例如[n,n]?

i want to make for loop in c# that enable me to fill unlimited array?
such as [n,n]?

推荐答案

for(int i=0; i<n; i++)
  for(int j=0; j<n;++j)
  {
    // Fill your array here
    // someArray[i][j] = "something";
  }


现在,您尝试失败的原因是什么?


Now what was in it that you failed to try?




首先,当使用普通数组时-大小不能无限.这意味着必须事先知道大小.

如果要填充二维数组,则需要两个嵌套的"for"循环.

任何基本的.net教程或书籍都可以在这里为您提供帮助.

最好的问候,

JF
Hi,

as first: when using a normal array - this can not be of unlimited size. This means that the size must be known before.

If you want to fill a 2 dimensional array you need two nested "for" loops.

Any basic .net tutorial or book should help you here.

Best regards,

JF


这篇关于数组中的for循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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