0
public class Ex
{
   public string example1{get;set;}
   public string example2{get;set;}
   public Test test{get;set;}
}    

public class Test
{
   public string example3 {get;set;}
 public long[] arrayLong{get;set;}
}

I have List listEx for example 10 elements. How get arraylong?

long[] result = listEx.Select( x=> x.Test.Select(y =>y.arrayLong)).ToArray();

I need only long[] how parse it?

0

2 Answers 2

3

Use SelectMany function, which will "flatten" collection of collections to one collection.

var result = listEx.SelectMany(ex => ex.Test.Select(test => test.arrayLong)).ToArray();

From MSDN: Enumerable.SelectMany Method

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

Comments

1

You should use SelectMany

var outresult = listEx.SelectMany(t => t.Test.Select(s => s.arrayLong)).ToArray();

Comments

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.