Ad

How To Split A String Into An Array But Only Split On The First Instance Of A Character (space In This Case)

- 1 answer

i have a string "ABC DEF EFG" and i want to get an array:

array[0] = "ABC"
array[1] = "DEF EFG"

Ad

Answer

Use the overload:

"ABC DEF EFG".Split(new char[] { ' ' }, 2)

This limits the number of return parts like you want.

Ad
source: stackoverflow.com
Ad