David John David John - 1 year ago 92
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?

Answer Source
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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download