list.Count problem

My code creates a list that eliminates same triple or higher value.

using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

public class list : MonoBehaviour
{
    List<int> onlydouble = new List<int>();
    int listLength;
    int checkdouble;
    int randno;

    void Start()
    {
        listLength = 7;
        Gener8only2dupli();

    }
    void Gener8only2dupli()
    {
        while (onlydouble.Count != listLength)
        {
            Debug.Log(onlydouble.Count);
            randno = Random.Range(0, 3);
            Debug.Log("randno" + randno);
            //Debug.Log("onlydouble" + onlydouble.Count);
            //for (int j = 0; j < MaxNumbers; j++)
            checkdouble = 0;
            foreach (int value in onlydouble)
            {
                //Debug.Log("a" + a + "j" + j);
                if (randno == value)
                {
                    Debug.Log("incremented");
                    checkdouble +=1;
                }

            }
            if (checkdouble > 2)
            {
                Debug.Log(randno + "greater than two");
            }
            else
            {
                onlydouble.Add(randno);
                Debug.Log("added" + randno);
            }

        }
    }
}

My problem is that when Debug.Log(onlydouble.Count); executes it says it has a new element added even thought it did not add a new element. What’s the proper way in checking the number of elements in generic list in Unity? Thanks

I don’t know what happened but when I run it again it runs smoothly. weird.