How to Split a String at newline in C# and VB.NET

To Split a String at newline in C# and VB.NET you can use the following snippet.

Sample C#

public static IEnumerable<String> SplitAtNewLine(string input)
{
	return input.Split(new[] { Environment.NewLine }, StringSplitOptions.None);
}

Sample VB.NET

Public Shared Function SplitAtNewLine(input As String) As IEnumerable(Of String)
	Return input.Split(New () {Environment.NewLine}, StringSplitOptions.None)
End Function

How to replace Html breaks with newline in C# and VB.NET

To replace Html breaks with newline in C# and VB.NET you can use the following snippet.

Sample C#

public static string HtmlBreaksToNewline(string input)
{
	return input.Replace("<br />", "\r\n");
}

public static string NewlineToHtmlBreaks(string input)
{
	return input.Replace("\r\n", "<br />");
}

Sample VB.NET

Public Shared Function HtmlBreaksToNewline(input As String) As String
	Return input.Replace("<br />", vbCr & vbLf)
End Function

Public Shared Function NewlineToHtmlBreaks(input As String) As String
	Return input.Replace(vbCr & vbLf, "<br />")
End Function