How can i check if a files already exist in the List?
<p>This is the code:</p>

<pre><code>for (int i = 0; i &lt; files.Count; i++)
{
    if (pdf1.Lightnings.Count == 0)
    {
        pdf1.Lightnings.Add(files[i]);
    }
    if (files[i] != pdf1.Lightnings[i])
    {
        pdf1.Lightnings.Add(files[i]);
    }
}
</code></pre>

<p>Both files and Lightnings are <code>List&lt;string&gt;</code></p>

<p>For example in files I have 33 indexes (files names) and I want to add them to the Lightnings List.
But I want to check that if the file name from the List of files already exist in Lightnings so don't add it again.</p>

<p>The way it is now I'm getting error since when the variable i=1 so the line:</p>

<pre><code>if (files[i] != pdf1.Lightnings[i])
</code></pre>

<p>Throws an error since in Lightnings i have only one index [0] and in i=1 already</p>
