SmackDat SmackDat - 1 year ago 74
C# Question

How to Create a string array by spliting a string?

I am kinda stuck at the moment, i have a string of numbers which i dynamically get them from database, the range of numbers can be between 1 to 1 milion, something like this :

string str = "10000,68866225,77885525,3,787";

i need to create an array from it, i have tried this:

string[] strArr = { str.Replace(",", "").Split(',') };

but it doesnt work anyone has any solution i am all ours. Basically it needs to be like this:

string[] strArr = { "10000","68866225","77885525","3","787" };

Answer Source

Try this:

string[] strArr = str.Split(',');
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download