David John David John - 1 month ago 5x
ASP.NET (C#) Question

How to split a string by a specific character?

Possible Duplicate:

How do i split a String into multiple values?

I have a string 0001-102525 . I want to split it into 0001 and 102525.How can i do it?

string myString = "0001-102525";
string[] splitString = myString.Split("-");

Then access either like so:

splitString[0] and splitString[1]

Don't forget to check the the count/length if you are splitting user inputted strings as they may not have entered the '-' which would cause an OutOfRangeException.