I have a List<MyObject> …
MyObject has a propert called LineId (integer)…
So, I need separate all consecutive LineId in List …
Example :
List<MyObject> :
LineId =1
LineId =1
LineId =1
LineId =2
LineId =1
LineId =2
The result must be 4 separeted lists:
LineId =1
LineId =1
LineId =1
-------------
LineId =2
-------------
LineId =1
-------------
LineId =2
So, I must separate all consecutive LineId …
Is there an easy way to do that using Linq?
Thanks
This looks ugly but the idea is clear and I think it works:
Here I am assuming that you have:
and
Now if I execute
I see:
printed on the console.