c# - how to split list using linq -


i have list of int consists of value 0,0,0,1,2,3,4,0,0 split 3 lists list consists 0,0,0 , list b consists 1,2,3,4 , list c consists 0,0.i know how split using if , for,but how can using linq. usual format need split in starting zeros , in middle values , in last zeros need split first zeros in 1 list ,middle values in 1 list , end zeros in list in example above here using linq , take index values.

first one.

mylist.takewhile(x => x==0) 

second one.

mylist.skipwhile(x => x==0).takewhile(x => x!= 0) 

third one.

mylist.skipwhile(x => x==0).skipwhile(x => x!= 0) 

Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -