c# - Concat not working - The underlying array is null -


i trying concat 2 array ienumerable lists , in result view says the underlying array null.

        ienumerable<objecttoconcat> result = new arraysegment<objecttoconcat>();          var lista = new list<objecttoconcat>();          var = new objecttoconcat          {officialid = guid.newguid(), firstname = "a object"};         lista.add(a);          var b = new objecttoconcat          {officialid = guid.newguid(), firstname = "b object"};         lista.add(b);          // error here result view         result = result.concat(lista);          var c = new objecttoconcat          {officialid = guid.newguid(), firstname = "c object"};         listb.add(c);          // error here result view         result = result.concat(listb); 

can please suggest me wrong code. or concat not work list?

it appear code:

ienumerable<objecttoconcat> result = new arraysegment<objecttoconcat>(); 

is attempt make empty enumerable. can more , writing:

ienumerable<objecttoconcat> result = enumerable.empty<objecttoconcat>(); 

that said, chaining lot of concat calls isn't effective, performance wise, if there lot of sub-lists. it's going perform bit better if create list<ienumerable<objectoconcat>> alllists, add of sub-lists list, , @ end can write:

result = alllists.selectmany(x => x); 

to flatten down list of items.


Comments

Popular posts from this blog

c++ - CryptStringToBinary API behavior -

java.util.scanner - How to read and add only numbers to array from a text file -

iphone - Three second countdown in cocos2d -