Find Duplicate entries C#
<p>I am new to programming so this may seem somewhat straightforward, but I cannot seem to figure it out.</p>

<p>I am trying to find duplicate values that are in a datatable in one column of the values. </p>

<p>Here is what I was trying to do it with.</p>

<pre><code>DataRow[] dupresults = dt.Select("PROV_NEW");
TableIssues = string.Empty;
DataTable dtTemp = dt.DefaultView.ToTable(true, "NEW_PROV");

if (dupresults.Length == 0)
{
    return true;
}
else
{
    foreach (DataRow item in dupresults)
    {
        Console.WriteLine(item[1]);
        TableIssues += "Provider Code is not unique for " + item[1].ToString() + ". Revise non-unique codes.\r\n\n\n\n";
    }
    return false;
}
</code></pre>

<p>Alright, but I am also having it search to make sure that there are no empty fields in PROV_NEW too. so I would not know where to put that. I am very new to c#. I just started last week. I am doing side projects for my father's company.</p>

<pre><code>private bool ValidateTable(DataSets.Setup.SETUP_MWPROVDataTable dt, out string TableIssues)
    {
        try
        {
            //NewCode not used for other row
            DataRow[] result = dt.Select("PROV_NEW = ''");
            DataRow[] dupresults = dt.Select("PROV_NEW");
            TableIssues = string.Empty;
            DataTable dtTemp = dt.DefaultView.ToTable(true, "NEW_PROV");



            if (dupresults.Length == 0)
            {

                return true;
            }
            else
            {
                var duplicates = dt.AsEnumerable()
               .Select(dr =&gt; dr.Field&lt;string&gt;("PROV_NEW"))
               .GroupBy(x =&gt; x)
               .Where(g =&gt; g.Count() &gt; 1)
               .Select(g =&gt; g.Key)
               .ToList();

                foreach (DataRow item in dupresults)
                {
                    Console.WriteLine(item[1]);
                    TableIssues += "Provider Code is not unique for " + item[1].ToString() + ". Revise non-unique codes.\r\n\n\n\n";
                }
                return false;
            }


            if (result.Length == 0)
            {
                //TODO: Add Next Step for validation

                return true;

            }
            else
            {
                foreach (DataRow item in result)
                {
                    Console.WriteLine(item[1]);
                    TableIssues += "Provider code " + item[1].ToString() + " is blank. Add new Provider code for " + item[1].ToString() +".\r\n\n\n";
                }


                return false;
            }

           }
        catch (Exception)
        {

            throw;
        }
    }


}
</code></pre>
