Luke Mcneice
Luke Mcneice

Reputation: 2720

Is it possible to Take object members directly from a queue of type object?

If I where to have a Queue holding a collection of objects (Custom object,bool,bool,bool,bool) and the custom object holds three doubles itself.

Can I use the .Take(IntegerValue) command to only take one of the doubles (for the specified take length) from the custom entity contained in the queue and cast it to a double array, possibly with the .ToArray<double> function?

Upvotes: 1

Views: 93

Answers (2)

Dan Bryant
Dan Bryant

Reputation: 27505

If your custom object contains a double array, then you can do something like this:

queue.OfType<CustomObject>().Select(o => o.doubleArray[0]).Take(1).ToArray();

Upvotes: 1

dkackman
dkackman

Reputation: 15559

queue.Select(o => o.Member).Take(integerValue).ToArray();

Upvotes: 1

Related Questions