目标数组不够长.检查destindex和length以及数组的下限

Use*_*007 3 c# arrays exception

我有一个包含以下代码的类:

  Array tags;
  if (lines.Length > 0)
  {
      configText = lines[0];
      tags = new Array[lines.Length];
      lines.CopyTo(tags,1);
  }
Run Code Online (Sandbox Code Playgroud)

在这里我收到以下错误:

目标数组不够长.检查destindex和length以及数组的下限.

方法:

     private bool ReadPointListFile(string fileName) {

        // Read each line of the file into a string array. Each element
        // of the array is one line of the file.
        string[] lines = System.IO.File.ReadAllLines(fileName);
        string configText = string.Empty;

        if (lines.Length > 0)
        {
            configText = lines[0];
            tags = new Array[lines.Length];
            lines.CopyTo(tags,1);
        }
        else
            lines.CopyTo(tags,0);

        GetConfigurationInfo(lines[0], out this.sInterval, out this.dataAggregate);

        return true;
    }
Run Code Online (Sandbox Code Playgroud)

jit*_*shi 5

它将从1个索引开始复制,而不是从零索引,它正在创建问题.尝试

lines.CopyTo(tags,0);
Run Code Online (Sandbox Code Playgroud)