There are times when you might want to split a string to array of strings based on delimiter in C#. This can be achieved by using the Split method defines in the string class.
How to Split a String with delimiter in C# ?
Below is a sample code snippet demonstrating how to split a string based on delimiter in C#.
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace GinktageConsoleApp
{
internal class Program
{
private static void Main(string[] args)
{
string InputString = "This is a test mesage from Ginktage.com";
char[] delimitter = new char[]{',',' '};
string[] OutputList = InputString.Split(delimitter);
foreach (string outPutString in OutputList)
{
Console.WriteLine(outPutString);
}
Console.ReadLine();
}
}
}