.net - Replacing the appendLine in string builder in c# -
i have stringbuilder builds string. after processed, saves sql server table used csv. how replace part of string including newline?
the code is:
stringbuilder temp = new stringbuilder(); temp.appendline("\"text 1 \""); temp.appendline(""); temp.appendline("\"my text \""); temp.appendline(""); temp.appendline("\"text 2 \""); temp.appendline("");
i want replace middle part can't correct because of newlines/carriage returns.
temp = temp.replace("\"my text \" ");
how grab newlines?
if want replace new line charcater, use '\n' (a special charcater) :
temp = temp.replace("\n","your_replacing_string");
or use environment.newline
:
temp = temp.replace(environment.newline,"your_replacing_string");
if want not append new line character in string builder :
- instead of
appendline()
, useappend()
not insert new line character.
Comments
Post a Comment