Checking two lists for equal items I'm using this code for checking if two List&lt;T&gt; are equal or not:

public static bool EqualsAll&lt;T&gt;(this IList&lt;T&gt; a, IList&lt;T&gt; b)
{
    if (a == null || b == null)
        return (a == null &amp;&amp; b == null);

    if (a.Count != b.Count)
        return false;

    EqualityComparer&lt;T&gt; comparer = EqualityComparer&lt;T&gt;.Default;

    for (int i = 0; i &lt; a.Count; i++)
    {
        if (!comparer.Equals(a[i], b[i]))
            return false;
    }

    return true;
}


Now assume that I'm using this code for checking two big lists. Is this code efficient?
Checking whether two lists are equal is naturally an O(n) operation. So yes, your code looks efficient.

Note that you could also replace your for loop with Enumerable.SequenceEqual

public static bool EqualsAll&lt;T&gt;(this IList&lt;T&gt; a, IList&lt;T&gt; b)
{
    if (a == null || b == null)
        return (a == null &amp;&amp; b == null);

    if (a.Count != b.Count)
        return false;

    return a.SequenceEqual(b);
}


If you take a look at its implementation, you'll notice that it's very similar to yours. It might be just a tiny bit less efficient - so if performance is an issue here, measure both approaches, and then weigh readability/maintainability vs performance gains.

On a different note, I would rename the method to SequenceEqual and consider it a "specialization" of Enumerable.SequenceEqual for lists.

I would also consider throwing an exception if either argument is null.
This would be consistent with the BCL's own extension methods (Select, Where, ToList, SequenceEqual, Any, All, etc).