How can I addConnection between two points indexes?
<p>I have this button click event and a addConnection function:</p>

<pre><code>private void button2_Click(object sender, EventArgs e)
{
    addConnection(cyclicSelectedIndex[0], cyclicSelectedIndex[1]);
}

private void addConnection(int i, int j)
{
    if (connectionStart.Count == 0)
    {
        connectionStart.Add(i);
        connectionEnd.Add(j);
    }

    for (int f = 0; f &lt; connectionStart.Count; f++)
    {
        if (connectionStart[f] == i &amp;&amp; connectionEnd[f] == j || connectionStart[f] == j &amp;&amp; connectionEnd[f] == i)
        {
        }
        else
        {
            connectionStart.Add(i);
            connectionEnd.Add(j);
        }

    }
}
</code></pre>

<p>In the click button I insert the int variables <code>i</code> and <code>j</code> two indexes. </p>

<p>Then in the addConnection function I'm using another two Lists.</p>

<p>First I check if the List is empty == 0 then add the two index to the Start List and to the End List.</p>

<p>Then I check in For loop if the two indexs are already exists in the connectionStart and/or the connectEnd Lists.</p>

<p>If they are not exists I will add them this is in the ELSE.</p>

<p>The problem so far is that when I put a break point in the ELSE area where I add the two indees to the lists.</p>

<p>First time its adding to each list one index. But if I then click the point again with another point and click the button then I see in both lists its adding the current indexes 8 times in each list. Then I select another two points click the button now its 16 then 32.</p>

<p>I don't understand why.</p>

<p>I want to that the last two points I clicked on and when I click the button to connect them and calling the function.</p>

<p>It will check to see if this two buttons connection already exists in the lists START and END and if not to add this connection to the lists.</p>

<p>So in the START connection I will have for example in index 0 the number 5 and in the END list in index 0 the number 7</p>

<p>Then in index 1 in START the number 9 and in the END in index 1 the number 10</p>

<p>And I know that in index 0 in both lists 5 and 7 are two points that have to be connected with a line. And so on 9 and 10.</p>

<p>Two problems:</p>

<ol>
<li><p>Ok Add instead = is working. But for some reason after clicked on two points if i click the button2 few times in a row it will add the same last two points indexs to the Lists START and END. I was sure that my check the IF suppose to check if this points connection already exist in the START and END lists so not ot add them again. Why is that ? my </p>

<p>if (connectionStart[f] == i &amp;&amp; connectionEnd[f] == j || connectionStart[f] == j &amp;&amp; connectionEnd[f] == i) isnt a good checking ? </p></li>
<li><p>Another problem now i added few points like 10. Then clicked button 2 to connect each two points. I click on one point and the click another point and its adding the points indexs to the cyclic List: cyclicSelectedIndex then in button2 click i use the addConnection function to get the two indexs each time of the last two points i clicked on. but i checked with breakpoint and i see that in the Lists START and END there some index of points that are the same one after one. like in the list START i see in index 4,5,6,7 i see 0,0,0,0 i dont know hwy it happen</p></li>
</ol>
