arrays - C# - store strings in List -


only working on c# 2 weeks. i've been searching on problem few days , cannot find simple answer, or answers don't want. here goes.

i reading text file line line (no problems).

example:

a line msh line 2 b line msh b line 2 b line 3 

i want store lines in list following ;

list lstore[0,0] = line msh      lstore[0,1] = line 2      lstore[1,0] = b line msh      lstore[1,1] = b line 2      lstore[1,2] = b line 3 

i've been using :

 list<string[]> lstore = new list<string[]();  

to define list.

i'm looping through file read

while ((sfilecontents = srfile.readline()) != null) {     boolean bmsh_start = sfilecontents.contains("msh");     if (bmsh_start)     {         // every time msh found want start new record in list         lstore.add(sfilecontents);     }     else     {         ????? //if not msh append current record in list     } } 

there can number of lines in group, distinguishing 'msh' appear on first line of every new group.

if lines starts a,b,c etc.. , first line contains msh can group them first letter instead.

var lines = file.readlines("filepath")              .groupby(x => x[0])              .select(x => x.toarray())              .tolist(); 

this give list<string[]> result.here result in linqpad:

enter image description here


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -