I have a text string with many ",". I would like to replace all "," with an Enter or a linebreak. How can achieve this? Thanks.
Asked
Active
Viewed 200 times
-5
-
4quick search brought this up, I think it's what your looking for https://stackoverflow.com/questions/224236/adding-a-newline-into-a-string-in-c-sharp – germas Jul 17 '15 at 00:53
-
1Note: Environment.NewLine is not *always* 'correct'. (Just because it comes up more of then naught; and generally without a disclaimer.) – user2864740 Jul 17 '15 at 01:07
-
For the record, I voted to close this as a duplicate of [this question](https://stackoverflow.com/questions/224236/adding-a-newline-into-a-string-in-c-sharp), not as too broad; Stack Overflow's closing mechanism is broken. – TylerH Jul 20 '15 at 19:26
2 Answers
1
yourString = yourString.Replace(",", System.Environment.NewLine);
Demo here https://dotnetfiddle.net/M2lBKS

gunr2171
- 16,104
- 25
- 61
- 88

Shreyas Chavan
- 1,079
- 1
- 7
- 17