-1

say I have an array with some strings in it

string[] array = {"item1", "item2"};

and now I want to use linq to on a single line take all the strings and put them into an array with a space between them I have tried

args.Select(x => x.ToString() + " ").ToString()

but this returns

Output Image

It is important to me that the code is on a single line of code, as it is not very clean in my standards or fitting to loop through with a foreach and add it to a string

0

1 Answer 1

6

Try String.Join(" ", array); it should do the trick

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.