Okay, the question could probably a phrased better. I have a string.
2008 apple micro pc computer
i want the string split by ' '
for the first 2 delimiters and then keep the rest together. so it'll return
2008
apple
micro pc computer
This is a made up string so it could be anything, but it's still first 2 split, then all the rest no matter how much is all the rest
Another example
apple orange this is the rest of my string and its so long
returns
apple
orange
this is the rest of my string and its so long
Pass a second argument to specify how many items at max to split into. In your case, you'd pass 3 so you have the first two parts split by space, and the rest of the string in the third.
string myString = "2008 apple micro pc computer";
string[] parts = myString.Split(new char[] { ' ' }, 3);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With