简体   繁体   中英

C# linq how to build expandoobjects into a list?

I am trying to select expandoobjects ( qs_ll[0][0] ) from List<dynamic> and build them into a new list.

I have managed to use GetRange() and .concat() to select and combine sublists. It does work, but it is rather verbose. I would fancy the index method as it looks tidy.

I currently trying like Enumerable.Concat(qs_ll[0][0],qs_ll[0][1]) . However, the result turn out to be a series of objects [column name,value] and it does not have ToList() . I would like it keep the structure of expandoobjects{value1,value2,value3,...}.

I assume it can be done with the use of certain functions.

Alright, I find the most straightforward way by myself (it is just there all the time).

new List<dynamic>{qs_ll[0][0], qs_ll[0][1]};

I have been thinking of it in a merging lists manner, forgetting the fact that those variables are just elements which would just build a list. To build elements into a list, how could it be done easier by just new List<>{ele1,ele2,...}; ?..

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM