
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to split a string with a string delimiter in C#?
Delimiters are the commas that you can see in the below string.
string str = "Welcome,to,New York";
Now set the delimiter separately.
char[] newDelimiter = new char[] { ',' };
Use theSplit() method to split the string considering the delimiter as the parameter.
str.Split(newDelimiter, StringSplitOptions.None);
To split a string with a string deli meter, try to run the following code −
Example
using System; class Program { static void Main() { string str = "Welcome,to,New York"; char[] newDelimiter = new char[] { ',' }; string[] arr = str.Split(newDelimiter, StringSplitOptions.None); foreach (string val in arr) { Console.WriteLine(val); } } }
Output
Welcome to New York
- Related Questions & Answers
- How to split string by a delimiter str in Python?
- Java regex program to split a string with line endings as delimiter
- How can we split a string by sentence as a delimiter in Java?
- How do we use a delimiter to split string in Python regular expression?
- How to Split a String with Escaped Delimiters?
- How to split a string into elements of a string array in C#?
- How to split a string in Java?
- How to split a string in Python
- How to split a string in Golang?
- Write a Python function to split the string based on delimiter and convert to series
- Java Program to split a string with dot
- Split a string in Java
- How to split a string using regular expressions in C#?
- How to split a Java String into tokens with StringTokenizer?
- C# program to split and join a string
Advertisements