-4

I had the string like in this format: string test="123_456_7890"; I need to convert this string into a string array like this:

string [] arr={"123","456","7890"};

Any help will be appreaciated.

Thanks Sabbu

Saverio Terracciano
  • 3,885
  • 1
  • 30
  • 42
Sabbu
  • 7
  • 5
  • string.Split do all the things that you are requesting (with just one line of code). Perhaps you should try to do some research before asking. – Steve Mar 13 '14 at 22:42

3 Answers3

1
string[] arr = test.Split('_');
Flat Eric
  • 7,971
  • 9
  • 36
  • 45
1

Just use:

string[] arr = test.Split('_');
Saverio Terracciano
  • 3,885
  • 1
  • 30
  • 42
-1

You can use the string functions to split it. String[] arr = test.split(new char[]{'_'}).ToArray();

Sirpingalot
  • 447
  • 1
  • 5
  • 11