Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I believe the easiest way is to use <a href="http://msdn.microsoft.com/en-us/library/system.linq.enumerable.sequenceequal.aspx" rel="nofollow noreferrer"><code>Enumerable.SequenceEqual</code></a> method.</p> <blockquote> <p>Determines whether two sequences are equal by comparing the elements by using the default equality comparer for their type.</p> </blockquote> <pre><code>bool equal = listOne.SequenceEqual(listTwo); </code></pre> <p>The <code>SequenceEqual&lt;TSource&gt;(IEnumerable&lt;TSource&gt;, IEnumerable&lt;TSource&gt;)</code> method enumerates the two source sequences in parallel and compares corresponding elements by using the default equality comparer for <code>TSource</code>, <a href="http://msdn.microsoft.com/en-us/library/ms224763.aspx" rel="nofollow noreferrer"><code>Default</code></a>. The default equality comparer, <code>Default</code>, is used to compare values of the types that implement the <a href="http://msdn.microsoft.com/en-us/library/ms132151.aspx" rel="nofollow noreferrer"><code>IEqualityComparer&lt;T&gt;</code></a> generic interface.</p> <p>As Tim <a href="https://stackoverflow.com/questions/17464413/is-there-any-way-to-compare-two-list-in-c-sharp#comment25377516_17464473">pointed</a>, if your items are not ordered, using <a href="http://msdn.microsoft.com/en-us/library/bb300779.aspx" rel="nofollow noreferrer"><code>Except</code></a> method looks better. For example;</p> <pre><code>bool equal = !listTwo.Except(listOne).Any(); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload