String Split in C#

Splits a string into parts based on delimiters and stores it into an string array.

char delimiters = {'delimiter1', 'delimiter2' };
string[] splitString = bigString.Split(delimiters);


A literal delimiter can be passed into the split method. The preferred method is to use a character array of delimiters, and pass that into the split method to consider multiple delimiters.

string pets = "dog,cat fish";
char[] delimiters = {' ', ','};
string[] petsArray = pets.Split(delimiters); //will split names using comma as delimiter
Console.WriteLine(petsArray[0]); //will output "dog"

< String Trim   |   String Representation >

© 2019 SyntaxDB. All Rights Reserved.