开发者

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

开发者 https://www.devze.com 2022-12-23 06:47 出处:网络
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.

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 containe开发者_运维问答d in the queue and cast it to a double array, possibly with the .ToArray<double> function?


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();


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

精彩评论

暂无评论...
验证码 换一张
取 消