c# - How can i add a space/empty line between the first and second lines in single string variable? -
string tables = this.webbrowser1.document.getelementbyid("tblproducts").innertext; using (stringreader reader = new stringreader(tables)) { string line; while ((line = reader.readline()) != null) { // line } } this did now:
string tables = this.webbrowser1.document.getelementbyid("tblproducts").innertext; streamwriter w = new streamwriter(@"c:\temp\table1.txt"); w.writeline(tables); w.close(); string[] lines = file.readalllines(@"c:\temp\table1.txt"); (int = 0; < lines.length; i++) { lines[i] = lines[i].insert(0, "here added text"); } but instead insert iwant somehow add new line between line number 1 , line number 2. if lines contain 31 lines in end should contain 32 lines new line between line 1 , line 2. not add new line end between 1 , 2.
i think you're saying that, given text looks this:
this line 1 second line here , third line what want is:
this line 1 <empty line here> second line here , third line if so, should pretty easy do:
string tables = this.webbrowser1.document.getelementbyid("tblproducts").innertext; var lines = tables.split(new[]{environment.newline}, stringsplitoptions.none).tolist(); lines.insert(1, ""); string newtext = string.join(environment.newline, lines);
Comments
Post a Comment