Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to resolve ambiguous ZIP call between Enumerable and MoreLINQ?
    primarykey
    data
    text
    <p>I've ran into problem with extension method resolution. LINQ and MoreLINQ contain <code>zip</code> method, it was present in .NET since <strong>4.0</strong> version and was always in <a href="http://code.google.com/p/morelinq/" rel="nofollow noreferrer">MoreLINQ</a> library. But you can't use one of the implementation with nice-old extension method syntax. So this code won't compile</p> <pre><code>using MoreLinq; using System.Linq; var students = new [] { "Mark", "Bob", "David" }; var colors = new [] { "Pink", "Red", "Blue" }; students.Zip(colors, (s, c) =&gt; s + c ); </code></pre> <p>Error:</p> <pre><code>The call is ambiguous between the following methods or properties: 'MoreLinq.MoreEnumerable.Zip&lt;string,string,string&gt; (System.Collections.Generic.IEnumerable&lt;string&gt;, System.Collections.Generic.IEnumerable&lt;string&gt;, System.Func&lt;string,string,string&gt;)' and 'System.Linq.Enumerable.Zip&lt;string,string,string&gt; (System.Collections.Generic.IEnumerable&lt;string&gt;, System.Collections.Generic.IEnumerable&lt;string&gt;, System.Func&lt;string,string,string&gt;)' </code></pre> <p>I've found good resolution for <code>Concat</code> method on <code>string</code> for MoreLINQ made by Jon Skeet at <a href="https://stackoverflow.com/questions/610870/when-do-extension-methods-break/610908#610908">this post</a>, but I'm not aware of good resolution for <code>zip</code> method. </p> <p><strong>NOTE:</strong> You can always use static method call syntax and it all works fine with </p> <pre><code>MoreEnumerable.Zip(students, colors, (s, c) =&gt; s + c ) </code></pre> <p>but misses the point of extension syntax sugar a little bit. If you have lots of data transformation with LINQ and MoreLINQ calls - you don't want to use static method call in the middle. </p> <p>Are there any better ways to resolve this ambiguity? </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.
 

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