c# - text files with string arrays get position substring -


i having problem following:

i loading file c# , splitting lines code.

// splitting line original file string[] lines = showtext.split(new string[] { "\r\n", "\n" }, stringsplitoptions.none); 

now need loop go through lines , substring lines, separately.

here trying accomplish, in way:

for (int = 0; < lines.length; i++) {     int[] testing = new int[i];     testing[i] = int.parse(lines[i].substring(16, 1));     textbox1.text = testing.tostring(); } 

the error here is: index outside bounds of array.

here picture better idea i'm trying do.

http://s30.postimg.org/jbmjmqv1t/work.jpg

textbox1.text = lines[0].substring(16,1) + "   " + lines[0].substring(23,9); textbox1.text = lines[1].substring(16,1) + "   " + lines[1].substring(23,9); //etc 

could me this?

you creating array in loop, being created each line , wrong length. instead of part of code:

for (int = 0; < lines.length; i++) {     int[] testing = new int[i];     testing[i] = int.parse(lines[i].substring(16, 1));     textbox1.text = testing.tostring(); } 

you should doing this:

int[] testing = new int[lines.length]; (int = 0; < lines.length; i++) {     testing[i] = int.parse(lines[i].substring(16, 1));     textbox1.text = testing.tostring(); } 

Comments

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -

Nuget pack csproj using nuspec -