小编use*_*015的帖子

使用此代码时,在c#中索引越界

如果我有1到100位数,我应该得到输出

1--100 
2--99
 3--98 
.  
.. 
.. 
49---50 
Run Code Online (Sandbox Code Playgroud)

代码低于其给定索引的范围,数组不需要很多维度

static void Main(string[] args)
{
    //// A. 2D array of strings.
    string[][] a = new string[100][];

    int bound0 = a.GetUpperBound(0);
    int bound1 = a.GetUpperBound(1);
    for (int i = 0; i <= bound0; i++)
    {
        for (int x = 100; x <= bound1; x--)
        {
            string s1 = a[i][x];
            Console.WriteLine(s1);
        }
    }
    Console.WriteLine();
    Console.ReadKey();
}
Run Code Online (Sandbox Code Playgroud)

c#

2
推荐指数
1
解决办法
733
查看次数

标签 统计

c# ×1