c# - Iterate through IEnumerable string array -


i'm reading multiple line text file has comma delimited values this:

 string[] lines = file.readalllines(path);  ienumerable<string[]> resultarray1 = lines.select(x => x.split(',')); 

in debug mode when @ results this:

 [0] drill down see [0] "3.22"                       [1] "4.00 

with following loop, can print out values, i'm not sure how without specifying [0] , [1] , i'm not sure how know line i'm on of file. have far:

  foreach (string line in lines)   {       foreach (string[] item in resultarray1)       {           console.writeline(item[0]);           console.writeline(item[1]);       }   } 

could show me missing?

for printing out separate elements in string[], use for loop:

  foreach (string[] item in resultarray1)   {       for(var = 0; < item.length; i++)           console.writeline(item[i]);   } 

as keeping track of line of file on, have separate variable keep track of or change foreach for. below variable implementation:

int line = 0; foreach (string line in lines) {     //code here      line++; } 

Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -