首页 > 解决方案 > 索引超出范围(C# 数组)

问题描述

当我将 path[i,50] 打印到控制台时,将打印路径。但是当我尝试从该路径读取流( FileStream stream = File.OpenRead(path[i,50]) 时,我在上面的行中得到索引超出范围

            string [,] path = new string [10,100];
            byte[][] fileBytes = new byte[10][]; 
            for (int i = 1; i <= 10; i++)
            {
                //defining path
                path[i, 50] = @"C:\Users\t-chkum\Desktop\InputFiles\1MB\" + i + ".txt";

               // Console.WriteLine(path[i,50]);
                    // readind data/* 
                FileStream stream = File.OpenRead(path[i,50]);
                fileBytes[i] = new byte[stream.Length];
                stream.Read(fileBytes[i], 0, fileBytes[i].Length);
                stream.Close();
            }

将不胜感激任何帮助:)

标签: c#.netmultidimensional-arrayjagged-arrays

解决方案


推荐阅读