Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Those extra parentheses do not change the meaning of those lambda expressions, nor how the compiler chooses to compile those two different blocks of code. Based on what you've provided, there appears to be no functional difference between your two choices and thus the problem is unrelated to the parentheticals.</p> <p><strong>EDIT:</strong></p> <p>So I created a quick class that does exactly what you stated, and the IL differs only in class names. I used <code>ildasm</code> and <code>windiff</code> to confirm this. Nor does it change with <code>/optimize-</code> or <code>/debug:full</code>.</p> <pre><code> .method /*06000005*/ public hidebysig instance bool '&lt;Main&gt;b__3'(class [mscorlib/*23000001*/]System.Tuple`2/*01000006*/&lt;int32,string&gt; var) cil managed // SIG: 20 01 02 15 12 19 02 08 0E { // Method begins at RVA 0x207c // Code size 22 (0x16) .maxstack 2 .locals /*11000001*/ init ([0] bool CS$1$0000) - .line 29,29 : 69,92 '' + .line 29,29 : 67,88 '' - //000029: if (listA.Any(var =&gt; (var.Item2 == strMatch)) || listB.Any(var =&gt; (var.Item2 == strMatch))) + //000029: if (listA.Any(var =&gt; var.Item2 == strMatch) || listB.Any(var =&gt; var.Item2 == strMatch)) IL_0000: /* 03 | */ ldarg.1 IL_0001: /* 6F | (0A)000005 */ callvirt instance !1 class [mscorlib/*23000001*/]System.Tuple`2/*01000006*/&lt;int32,string&gt;/*1B000001*/::get_Item2() /* 0A000005 */ IL_0006: /* 02 | */ ldarg.0 - IL_0007: /* 7B | (04)000001 */ ldfld string Parentheses/*02000002*//'&lt;&gt;c__DisplayClass6'/*02000003*/::strMatch /* 04000001 */ + IL_0007: /* 7B | (04)000001 */ ldfld string NoParentheses/*02000002*//'&lt;&gt;c__DisplayClass6'/*02000003*/::strMatch /* 04000001 */ IL_000c: /* 28 | (0A)000006 */ call bool [mscorlib/*23000001*/]System.String/*01000007*/::op_Equality(string, string) /* 0A000006 */ IL_0011: /* 0A | */ stloc.0 IL_0012: /* 2B | 00 */ br.s IL_0014 </code></pre> <p><strong>Nota bene:</strong> there are two of these generated, one for each of the <code>listX.Any</code> calls. Both only differ in their comments. The generated IL is identical.</p> <p><strong>EDIT 2:</strong></p> <p>The output from <code>ildasm</code> for Visual Studio 2008 (csc 3.5.30729.4926) is also no different, so I'm really unable to say why in your instance of VS2k8 it dies besides perhaps the version of LINQ you have is bugged or the compiler on that machine has a bugged Expression generator, because I cannot replicate any difference.</p>
 

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