adding GameObjects to a list

I’m trying to add unique GameObjects to a list, for example, each time I collide with an object, I add it to the list, but if I collide with that same object, I do not want to add it to the list again. I have the following:

#addEnemy.cs

if (col.gameObject.tag == "NPC")
{
    enemyDatabase.addEnemy(col.gameObject);
}

#enemyDatabase.cs

public List<GameObject> enemies = new List<GameObject>();


    public void addEnemy(GameObject currentEnemy)
    {
        
        Debug.Log("outside");
        foreach (GameObject enemy in enemies)
        {
            Debug.Log("checking");
            if (currentEnemy.name == enemy.name)
            {
                Debug.Log("Already in database");
            }
            else
            {
                enemies.Add(currentEnemy);
            }

        }
    }

if i remove the foreach and just add to the database, it works, only the same enemy is added to the database multiple times, I’m assuming the foreach does not run as there are no GameObjects inside of it at the beginning.

Does anyone know a way I can get around this?

Try this:

void addEnemy(GameObject currentEnemy) {

    if(!enemies.Contains(currentEnemy))

      enemies.Add(currentEnemy);

}

Can we destroy the complete list at once using destroy(enemies); or do we need to use foreach (GameObject enemy in enemies){destroy(enemy)}; ?

,Can we destroy the complete list at once or do we need to use foreach (…) for every gameObject in that list?