Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to split with more than a char?

Tags:

c#

split

I want to split at spaces, newlines, and commas.

Here is where I split with the space char:

StreamReader sr1 = new StreamReader("E:\\Lectures\\Fourth year\\2nd term\\IR\\Sections\\Files\\Files\\Document2.txt");
string doc = sr1.ReadLine();
string[] docArr = doc.Split(' ');
like image 738
Nouran Avatar asked Jan 17 '23 17:01

Nouran


1 Answers

You can pass in an array of chars.

string[] docArr = doc.Split(new char[]{' ', '\n', ','});
like image 132
Marty Avatar answered Jan 20 '23 15:01

Marty