Copy between variable length arrays c# -


so have string array called page , string array called notessplit created using notes.split().

notessplit have variable number of newlines never on 10 lines.

i'd overwrite contents of "page" index 20 - 30 leaving blank lines if index not exist in notessplit.

any ideas?

var page = new string[44]; <-- text file string notes = "blah \n blah \n";     string[] notessplit = notes.split(new string[] { environment.newline }, stringsplitoptions.none); 

what have come is:

for (var = 0; < 9; i++)  {    if (notessplit[i] != null)    {      page[i + 20] = notessplit[i];    } else {      page[i + 20] = system.environment.newline;    }  } 

i'm pretty sure you're looking for.

public string[] replace(string[] page, string[] notes, int start, int length) {   for(var = 0; + start < page.length && < length; i++)   {     if(notes != null && notes.length > (i))       page[i+start] = notes[i];     else       page[i+start] = enviroment.newline;   }    return page; } 

Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -