Problem with iterating through a list of Vector3s

Hello! I am very new to Unity and C#, and I just ran into a problem. I am attempting to iterate through a list of Vector3s, where the list must contain duplicates of Vector3s in some cases. However, when I use a foreach loop to do it, the loop seems to skip the duplicates for some reason. Why is that?

An example case:

void Start()
{

    // Simple test using Debug.Log

    List<Vector3> testList = new List<Vector3>();
    testList.Add(new Vector3(1, 2, 3));
    testList.Add(new Vector3(1, 2, 3));
    testList.Add(new Vector3(1, 2, 4));

    float testCount = 0;
    Debug.Log(testList.Count);     // This tells me the list contains the duplicate
    foreach (Vector3 pt in testList)
    {
        Debug.Log(pt);
        testCount += 1;
    }

    Debug.Log(testCount);   //  This tells me the foreach loop iterates completely
}

This outputs the following in the console:

3
(1.0, 2.0, 3.0)
(1.0, 2.0, 4.0)
3

While I would expect it to output:

3
(1.0, 2.0, 3.0)
(1.0, 2.0, 3.0)
(1.0, 2.0, 4.0)
3

Any help would be greatly appreciated!

It’s the console itself that collapses identical output lines, the number on the right edge of the console windows shows how often that particular output was “seen”. Uncheck the “collapse” button in the console window and you should see all individual lines.