Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to select sections of differing lengths from list using LINQ only
    primarykey
    data
    text
    <p>I have a List of a type named 'Complex':</p> <pre><code>List&lt;Complex&gt; list = new List&lt;Complex&gt;(); ... class Complex { public string Header { get; set; } ... ... ... } </code></pre> <p>There are some repeated headers in list, and these indicate the start of new sections. Each section may be of a different length, as shown below:</p> <pre><code>start 1 2 3 4 5 6 7 start 1 2 3 start 1 2 3 4 5 6 start 1 start 1 2 </code></pre> <p>I would like to get all possible sublists of type Complex using LINQ; that is, all objects with headers, as follows:</p> <ul> <li>1 2 3 4 5 6 7</li> <li>1 2 3</li> <li>1 2 3 4 5 6</li> <li>1</li> <li>1 2</li> </ul> <p>How can I accomplish this using LINQ only?</p> <p>edit: List is created during html page parsing</p> <pre><code>&lt;tr&gt; &lt;td&gt;00:00&lt;!--//-00:00--&gt;&lt;/td&gt; &lt;td&gt;15:00&lt;!--//-00:00--&gt;&lt;/td&gt; &lt;td class="txt_left"&gt;&lt;a href=""&gt;News&lt;/a&gt;&lt;/td&gt; &lt;td&gt;&lt;a href="/TsV2/TV_Video_On.asp?PROG_CODE=TVCR0114"&gt; &lt;img src="/images/new/sub_new/icon_play01_off.gif" alt="play" class="rollover"/&gt;&lt;/a&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;00:15&lt;!--//-00:00--&gt;&lt;/td&gt; &lt;td&gt;15:15&lt;!--//-00:00--&gt;&lt;/td&gt; &lt;td class="txt_left"&gt; &lt;a href="Tv_Pagego.asp?PROG_CODE=TVCR0556"&gt;Nice one&lt;/a&gt;&lt;/td&gt; &lt;td&gt;&lt;a href="/TV2w/TV_2Video_On.asp?PROG_CODE=TVCR0556"&gt;&lt;img src="/images/new/sub_new/icon_play01_off.gif" alt="play" class="rollover"/&gt;&lt;/a&gt;&lt;/td&gt; &lt;/tr&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload