Linked Questions

2 votes
4 answers
30k views

How to remove \n in a string? E.g. Input : string s = "\n1234" Output I want (but I can't achieve) : string s = "1234" What I've tried (and failed) : s.Remove(0,1); s.Trim(); Additional notes : I ...
Moses Aprico's user avatar
  • 2,161
2 votes
2 answers
9k views

Possible Duplicate: Replace Line Breaks in a String C# hi I have an textarea which anyone can enter text, where they can put line breaks inside the text area. How can I remove the line breaks ...
rob waminal's user avatar
  • 18.5k
1 vote
1 answer
2k views

I need to replace New Line with <br> in the string obtained from a text box.Currently i use this string text= textbox.Text; text.Replace(System.Environment.NewLine, "<br>"); But nothing ...
techno's user avatar
  • 6,604
0 votes
1 answer
2k views

I'm getting a string from an external native library function which uses "\n" for line separation. I simply want to write this to disk using the appropiate line ending format on the system I'...
Florian Storck's user avatar
1 vote
3 answers
1k views

i have this string var str="\r\nFeatures\r\nWins\r\n\r\n"; i want split on "\r\n" but between two "\r\n\r\n" have value null or whitespace i want get result 3 items = Features Wins nullorwhitespace ...
jack wilsher's user avatar
-1 votes
2 answers
898 views

I'm receiving a random line break in the following C# string and can't identify why the output is on two separate lines. I've really only tried to define the variable in two different manners. Both ...
Ryan Brown's user avatar
-3 votes
1 answer
190 views

How can I replace the line break of a textbox (multiline-box) by the html's <br>? This is my code: string output = tb_Notizen.Text.Replace("\\r\\n", "<br>"); Whats wrong here? I ...
bbholzbb's user avatar
  • 1,962
0 votes
0 answers
76 views

I have written an app to compare the response I get for a request with its standard response. If they differ I need to find the difference. Since the response I get for the request has \r and \n in ...
Kalpa-W's user avatar
  • 358
51 votes
12 answers
66k views

I have a need to get rid of all line breaks that appear in my strings (coming from db). I do it using code below: value.Replace("\r\n", "").Replace("\n", "").Replace("\r", "") I can see that there's ...
IamDeveloper's user avatar
  • 5,254
10 votes
6 answers
21k views

I'm currently creating an application using ASP.NET MVC. I got some user input inside a textarea and I want to show this text with <br />s instead of newlines. In PHP there's a function called ...
maff's user avatar
  • 773
12 votes
5 answers
10k views

I have a string that has some Environment.Newline in it. I'd like to strip those from the string and instead, replace the Newline with something like a comma. What would be, in your opinion, the ...
Martin Marconcini's user avatar
11 votes
2 answers
11k views

So I know how to replace newlines in my C# code. But replacing a newline for a <br /> tag isn't always very correct. So I was wondering what kind of strategy do others use? The correct way I ...
Pickels's user avatar
  • 34.7k
5 votes
6 answers
22k views

I have the following code: StringBuilder sb = new StringBuilder(); sb.Append("Ola"); sb.Append("Jola"); sb.Append("Zosia"); Can I iterate over StringBuilder object using for, or foreach? Can I ...
Piotr Wozniak's user avatar
1 vote
5 answers
10k views

private void btnDump_Click(object sender, EventArgs e) { using (StreamWriter sw = new StreamWriter("E:\\TestFile.txt")) { // Add some text to the file. sw.WriteLine(txtChange....
Dan1676's user avatar
  • 1,745
5 votes
3 answers
12k views

Im reading file in as a stream: Stream fin = File.OpenRead(FilePath); Is there any way how i would be able to find and remove all carriage returns from that file stream? EDIT: The goal is to remove ...
hs2d's user avatar
  • 6,239

15 30 50 per page