Counting rows in a CSV file that correspond to a database row, each with a million records
Your inner loop appears to be unnecessary. Why not create a lookup:

var knownAccountNumbers = new HashSet&lt;string&gt;(
    dataStructure.Tables["AccountData"].Rows
        .Cast&lt;DataRow&gt;()
        .Select(row =&gt; row[0].ToString()));


Now your loop is simply:

foreach (DataRow row in dt.Rows)
{
    var accountNumber = row[0].ToString().Replace("\"", "");
    row[12] = knownAccountNumbers.Contains(accountNumber) ? "Y" : "N";
}


I think I remember reading once that the memory usage of a HashSet is 12 bytes per entry + size of the entry. So you're looking at 12MB + 1,000,000 * (2 * accountNumber.Length). So basically nothing in the grand scheme of things. However, you are gaining constant time lookups which should be a huge benefit to this kind of work.



You should take more care when naming things. Don't abbreviate e.g. acctNum -> accountNumber.