CSharp examples for System:String New Line
Convert Bars To Line Breaks
using System;// w w w .j a v a 2s . c o m public class Main{ public static string ConvertBarsToLineBreaks(string originalList) { string[] newLineDelimiters = { Environment.NewLine }; char[] barDelimiter = { '|' }; string[] rawItemList = originalList.Split(barDelimiter); string trimmedItem = ""; string newList = ""; foreach (string rawItem in rawItemList) { trimmedItem = rawItem.Trim(); if (string.IsNullOrEmpty(trimmedItem)) continue; // ignore blank items if (!string.IsNullOrEmpty(newList)) newList += Environment.NewLine; // Add a newline if there is already a string in there newList += trimmedItem; } newList = newList.TrimEnd('\r', '\n'); //remove the last "newline" if items exists return newList; } }