linq group by contiguous blocks

前端 未结 5 1422
长情又很酷
长情又很酷 2020-12-02 00:01

Let\'s say I have following data:

Time Status
10:00 On
11:00 Off
12:00 Off
13:00 Off
14:00 Off<

5条回答
  •  爱一瞬间的悲伤
    2020-12-02 00:09

    It can be done as.

    1. Iterate over collection.
    2. Use TakeWhile condition is text of first element of collection On or Off.
    3. Iterate over the subset of from point one and repeat above step and concatenate string.

    Hope it helps..

提交回复
热议问题