How do i check if the List length is bigger than the last time?
<p>I have this code:</p>

<pre><code>int LRLength = LR.Count;
            for (int i = 0; i &lt; LR.Count; i++)
            {
                LRLength = LR.Count;
                LR = merge(LR);
                if (LR.Count &lt; LRLength)
                {
                    LR = merge(LR);
                    if (LR.Count == LRLength)
                    {
                        break;
                    }
                }
            }
</code></pre>

<p>And this is the function merge:</p>

<pre><code>private List&lt;Lightnings_Extractor.Lightnings_Region&gt; merge(List&lt;Lightnings_Extractor.Lightnings_Region&gt; Merged)
        {
            List&lt;Lightnings_Extractor.Lightnings_Region&gt; NewMerged = new List&lt;Lightnings_Extractor.Lightnings_Region&gt;();
            Lightnings_Extractor.Lightnings_Region reg;
            int dealtWith = -1;
            for (int i = 0; i &lt; Merged.Count; i++)
            {
                if (i != dealtWith)
                {

                    reg = new Lightnings_Extractor.Lightnings_Region();

                    if (i &lt; Merged.Count - 1)
                    {

                        if (Merged[i].end + 1 &gt;= Merged[i + 1].start)
                        {
                            reg.start = Merged[i].start;
                            reg.end = Merged[i + 1].end;
                            NewMerged.Add(reg);
                            dealtWith = i + 1;
                        }
                        else
                        {
                            reg.start = Merged[i].start;
                            reg.end = Merged[i].end;
                            NewMerged.Add(reg);
                        }
                    }
                    else
                    {

                        reg.start = Merged[i].start;
                        reg.end = Merged[i].end;
                        NewMerged.Add(reg);

                    }
                }
            }
            return NewMerged;
        }
</code></pre>

<p>In this class: Lightnings_Extractor.Lightnings_Region I have only two int variables.
The idea in this function is to get a List and merge areas that are congruent.</p>

<p>For example once im calling the function and the List LR Length is 8 now I will get it back less. For example if it needed to merge two indexs to one then the List I will get in return the Length will be 7. If it will need to merge another indexs then the Length will be 6 and so on.</p>

<p>What I want to check on the first code above is when I should stop calling the function to merge indexs. </p>

<p>If the length was 8 and the next time it's still 8 do nothing stop the loop.
If the length is 8 and the next time it's 7 then call the function again.
If the length is 7 stop the loop . But if the length is 6 keep calling it once again.</p>

<p>Untill the last length will be the same as the length before !!!</p>

<p>So I tried this code but it's not working good:</p>

<pre><code>int LRLength = LR.Count;
                for (int i = 0; i &lt; LR.Count; i++)
                {
                    LRLength = LR.Count;
                    LR = merge(LR);
                    if (LR.Count &lt; LRLength)
                    {
                        LR = merge(LR);
                        if (LR.Count == LRLength)
                        {
                            break;
                        }
                    }
                }
</code></pre>
