last day (14 days later) » 

4:11 AM
1
A: How to Split item of array?

dotctorYou can do it via linq and use SelectMany var word = new string[3]; word[0] = "Listen Repeat"; word[1] = "Tune"; word[2] = "Landing Page"; word = word.SelectMany(x => Regex.Split(x, @"\s{1,}").Where(y => !string.IsNullOrEmpty(y))).ToArray();

 
But I want my array like: "Listen" "Repeat" "Tune" "Landing Page"
Dump method can confuse people. The code will not compile
 
@DmitryDovgopoly I tested. It working in my case. I not using word.Dump();.
It working for me. Thank you very much @dotctor.
 
@VănLộc but this solution splits every element. You will get "Landing" and "page" as different elements
 
I don't look this until reading your comment. Yes, I only check and split the first element.
Are you know how to check only first element?
 
Add a method to the answer where get input index of the item you want to split.
 
4:19 AM
Like: words = words.SelectMany(x => Regex.Split(x, @"\s{1,}").Where(y[0] => !string.IsNullOrEmpty(y[0]))).ToArray(); ?
 
See the edits on my answer. @VănLộc
 
@dotctor
I tried with your answer edited. But it also split every element from 0 -> 3
Ok.
I test with data fails
Your answer right in my case.
Thanks, @dotctor
 
4:40 AM
I'm glad it helped. @VănLộc
 
5:04 AM
You awesome.
 

last day (14 days later) »