Comparing two lists to find the difference

So I am shooting coloured darts at a spinning board. When the dart hits the board it will perform a check using Physics2D.OverlapCircleAll for any nearby darts which are of the same colour. If there are any detected it will add them to a list called Links. I want to be able to compare the other dart’s Link list with the current dart and if there is any differences to be able to add that to the current list.

![public class DartOptimized : MonoBehaviour
{

    // Speed of the Dart
    public float Velocity;

    // Board transform
    Transform boardTransform;
    // This dart transform
    Transform thisDartTransform;
    //This dart layer
    LayerMask thisLayer;

    // Stopping distance for dart
    public float boardContact;

    // Distance to check for surrounding darts once contact is made with the board
    public float checkRadius;

    // Links list
    public List<GameObject> Links = new List<GameObject>();
    // Material for line 
    public Material LineRenderMat;


    // Game Manager Script for score
    GameManagerScript GM;


    public Collider2D[] checkForSurroundingDarts;


    private void Start()
    {
        boardTransform = GameObject.FindGameObjectWithTag("Board").transform;
        thisDartTransform = gameObject.transform;
        thisLayer = gameObject.layer;

        GM = GameObject.FindObjectOfType<GameManagerScript>();
    }


    private void Update()
    {
        if (gameObject.tag == "Dart")
        {

            // Distance between the board and this dart
            float distance = Vector3.Distance(boardTransform.position, thisDartTransform.position);
            if (distance > boardContact)
            {
                // Move Dart
                transform.Translate(new Vector3(0f, Velocity * Time.deltaTime, 0f));
            }
            else
            {
                gameObject.tag = "Pinned";
                Invoke("AttachDartToBoard", 0);
            }
        }
    }

    private void AttachDartToBoard()
    {
        this.gameObject.transform.SetParent(boardTransform);
        GM.scoreValue++;

        checkForSurroundingDarts = Physics2D.OverlapCircleAll(transform.position, checkRadius);
        for (var i = 0; i < checkForSurroundingDarts.Length; i++)
        {
            if (checkForSurroundingDarts_.gameObject.tag == "Pinned" && checkForSurroundingDarts*.gameObject.layer == this.gameObject.layer)*_

{
if (checkForSurroundingDarts*.gameObject.GetComponent().Links.Count <= 1)*
{
Links.Add(checkForSurroundingDarts*.gameObject);*
}
else if (checkForSurroundingDarts*.gameObject.GetComponent().Links.Count > 1)*
{
Links.Add(checkForSurroundingDarts*.gameObject);*

//Links.AddRange(checkForSurroundingDarts*.gameObject.GetComponent().Links);*
}
}
}
}][1]
_*

List have a function Contains, it will check if Object is in list or not.


public class MyCode: MonoBehaviour
{

    private List<GameObject> m_myList;
    private GameObject m_myGameObject;


    void Check()
    {
        if (ListContains(m_myList, m_myGameObject))
            Debug.Log("It already has this Gameobjet");
        else
            Debug.Log("We don't have this GameObject in this list");
    }

    private bool ListContains(List<GameObject> _list,GameObject _gameObj)
    {
        if (_list.Contains(_gameObj))     
            return true;
        else
            return false;
    }
}

UPDATED:

So if you want to compare listOne and listTwo, and add all elements that is not in List Two, just use:


    void Check(List<GameObject> _listOne, List<GameObject> _listTwo)
    {
        foreach (GameObject _GO in _listOne)
        {
            if (!_listTwo.Contains(_GO))
                _listTwo.Add(_GO);
        }
    }