Split the String with given Delimiters C#

By Mash B

Split the string into array with given Delimiters.

Ex.

  string commaSeperatedValue = "A,B,C,D"
  
  // Declare Delimit ; change the delimit according to requirement
  char[] delimiter = {','};
  // Call split method and pass delimiter to aplit
  
  string[] valueArray = commaSeperatedValue.Split(delimiter,StringSplitOptions.RemoveEmptyEntries);
  
  //Loop through all values using foreach
  
  foreach(string value in valueArray)
  {
     console.writeln(value);
  }

Split the String with given Delimiters C#  (770 Views)