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

Please Share us:
Please rate this snippet

One thought on “How to Split a String at newline in C# and VB.NET

Leave a Reply