Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The exact opposite of <code>All()</code> is essentially <code>None</code>, but since LINQ has no <code>None()</code> method, you can accomplish the same result through <code>!set.Any()</code>.</p> <pre><code>!a_list.Any(item =&gt; !(item.matches == true)) </code></pre> <p>This will produce <code>true</code> if none of the items in a_list have a <code>matches</code> value that is not true. </p> <p>That double negative is a bit confusing, so to provide a simpler example:</p> <pre><code>names.All(item =&gt; item.StartsWith("R")) </code></pre> <p>is true if <strong>all</strong> of the items in <code>names</code> start with R (as you know already).</p> <pre><code>!names.Any(item =&gt; item.StartsWith("R")) </code></pre> <p>is true if <strong>none</strong> of the items in <code>names</code> start with R.</p> <p>Based on your comment below, it sounds like you might just be looking for a way to accomplish the same result as your current code snippet, but in a different way. This should provide the same result as your current code, but without the <code>!</code> in the predicate:</p> <pre><code>!a_list.Any(item =&gt; item.matches == true) </code></pre> <p>This can be further simplified to:</p> <pre><code>!a_list.Any(item =&gt; item.matches) </code></pre> <p>I'd imagine yours could be simplified as well, to this:</p> <pre><code>a_list.All(item =&gt; !item.matches) </code></pre> <p>There's rarely a good reason to explicitly compare a boolean value with <code>true</code> or <code>false</code>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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