How to Split a String on newlines in C#?

Ever wanted to split an input string in to new lines in .NET (c#) that has a new line character? Below is a sample code snippet that demonstrates how to do it.

How to Split a String on newlines in C#?

using System;

using System.Collections.Generic;

using System.Data;

using System.DirectoryServices.AccountManagement;

using System.IO;

using System.Linq;

using System.Net;

using System.Net.Sockets;

namespace AbundantCode

{

internal class Program

{

// How to Split a String on newlines in C# ?

private static void Main(string[] args)

{

string input = "ABundantcode.com \n is a \n Programming website";

string[] AllInputs = input.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);

foreach(var item in AllInputs)

Console.WriteLine(item);

Console.ReadKey();

}

}

}
How to Split a String on newlines in C#?