2

A have the string array and I need to select 9 elements starting from 20:

 string sel = data.Skip(19).Take(9).ToString();

Where is error?

SOLUTION:

string sel = String.Concat(data.Skip(19).Take(9).ToArray());

1 Answer 1

2

Take(9) returns an IEnumerable<string>. When you call ToString() on it you just get the name of the type. You need to do this instead:

var selected = data.Skip(19).Take(9).ToArray();

selected is now of type string[] and should contain 9 elements (if data contains enough elements, that is).

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

5 Comments

why do you need ToArray? it will consume extra memory that might be not needed
Thanks, but I would not array.
@user348173 then what do you want? Can you clarify the question a bit?
string sel = String.Concat(data.Skip(19).Take(9).ToArray());
@Andrey, I just added ToArray because the OP was talking about arrays.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.