How do i loop through two Lists to compare items in both Lists?
<p>I have this code:</p>

<pre><code>private void removeDuplicates(List&lt;string&gt; currentSites, List&lt;string&gt; visitedSites)
        {
            for (int i = 0; i &lt; currentSites.Count; i++)
            {
                for (int x = 0; x &lt; visitedSites.Count; x++)
                {

                }
            }                    
        }
</code></pre>

<p>Im getting two Lists and i need first to compare each item in one List to the items in the other List to loop over all the items in the other List and compare. If one of the items exist in the other List mark it as NULL.</p>

<p>I need to check that visitedSites are in the currentSites to take one item move over all the Lists to check if exit if it is to mark as null.</p>

<p>In any case i need to use two loop's one ine the other one.</p>

<p>When i find its null to mark it null and after it make break;</p>

<p>Then i need to add another loop FOR to move over the List currentSites if im not wrong and remove all the marked NULL items.</p>

<p>The idea is to compare the Lists by mark the duplicated items as null then to remove all the null's.</p>

<p>This is the code from the beginning:</p>

<pre><code>using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using HtmlAgilityPack;
using System.IO;
using System.Text.RegularExpressions;
using System.Xml.Linq;
using System.Net;
using System.Web;


namespace GatherLinks
{
    public partial class Form1 : Form
    {
        List&lt;string&gt; currentCrawlingSite;
        List&lt;string&gt; sitesToCrawl;
        int actual_sites;
        BackgroundWorker worker;
        int sites = 0;
        int y = 0;
        string guys = "http://www.google.com";

        public Form1()
        {
            InitializeComponent();

            currentCrawlingSite = new List&lt;string&gt;();
            sitesToCrawl = new List&lt;string&gt;();
            actual_sites = 0;
                    }

        private void Form1_Load(object sender, EventArgs e)
        {

        }


        private List&lt;string&gt; getLinks(HtmlAgilityPack.HtmlDocument document)
        {

            List&lt;string&gt; mainLinks = new List&lt;string&gt;();
            var linkNodes = document.DocumentNode.SelectNodes("//a[@href]");
            if (linkNodes != null)
            {
                foreach (HtmlNode link in linkNodes)
                {
                    var href = link.Attributes["href"].Value;
                    mainLinks.Add(href);
                }
            }
            return mainLinks;

        }


        private List&lt;string&gt; webCrawler(string url, int levels , DoWorkEventArgs eve)
        {
                HtmlAgilityPack.HtmlDocument doc;
                HtmlWeb hw = new HtmlWeb();
                List&lt;string&gt; webSites;// = new List&lt;string&gt;();
                List&lt;string&gt; csFiles = new List&lt;string&gt;();

                csFiles.Add("temp string to know that something is happening in level = " + levels.ToString());
                csFiles.Add("current site name in this level is : " + url);
                                try
                {
                    doc = hw.Load(url);
                    currentCrawlingSite.Add(url);
                    webSites = getLinks(doc);
                    removeDuplicates(currentCrawlingSite, webSites);
                    removeDuplicates(currentCrawlingSite, sitesToCrawl);
                    sitesToCrawl = webSites;



                    if (levels == 0)
                    {
                        return csFiles;
                    }
                    else
                    {


                        for (int i = 0; i &lt; webSites.Count() &amp;&amp; i &lt; 20; i++)                         {
                            int mx = Math.Min(webSites.Count(), 20);

                            if ((worker.CancellationPending == true))
                            {
                                eve.Cancel = true;
                                break;
                            }
                            else
                            {

                                string t = webSites[i];
                                                                if ((t.StartsWith("http://") == true) || (t.StartsWith("https://") == true)) 
                                {

                                        actual_sites++;
                                        csFiles.AddRange(webCrawler(t, levels - 1,eve));
                                        this.Invoke(new MethodInvoker(delegate { Texts(richTextBox1, "Level Number " + levels + " " + t + Environment.NewLine, Color.Red); }));
                                        worker.ReportProgress(Math.Min((int)((double)i / mx * 100),100));



                                }
                            }
                        }

                        return csFiles;
                    }



                }
                catch
                {
                    return csFiles;
                }

        }
</code></pre>

<p>So im calling the removeDuplicated function twice need to do in the removeDuplicated the things i wrote above then im not sure if to do sitesToCrawl = webSites; or ot add somehow the links in webSites to the sitesToCrawl. The idea is when i loop over the webSites that there will be no duplicated items when adding to the csFiles List.</p>
