How to solve the error cannot be inferred from the usage. Try specifying the type arguments explicitly?
<pre><code>static Func&lt;T, object&gt; CreateSelector&lt;T&gt;(IEnumerable&lt;string&gt; propertyNames)
{
    var sourceType = typeof(T);
    var parameter = Expression.Parameter(sourceType, "e");
    var properties = propertyNames.Select(name =&gt; Expression.PropertyOrField(parameter, name)).ToArray();
    var selector = Expression.Lambda&lt;Func&lt;T, object&gt;&gt;(
        Expression.Call(typeof(Tuple), "Create", properties.Select(p =&gt; p.Type).ToArray(), properties),
        parameter);
    return selector.Compile();
}
public static IEnumerable&lt;Tuple&lt;T, T&gt;&gt; Join&lt;T&gt;(this IEnumerable&lt;T&gt; left, IEnumerable&lt;T&gt; right, IEnumerable&lt;string&gt; propertyNames)
{
    var keySelector = CreateSelector&lt;T&gt;(propertyNames);
    return left.Join(right, keySelector, keySelector, Tuple.Create);
}
public static bool CompareLists&lt;T1, T2&gt;(IEnumerable&lt;T1&gt; lstProduct1, IEnumerable&lt;T2&gt; lstProduct2, List&lt;DuplicateExpression&gt; DuplicateExpression)
{
    string[] Fields = DuplicateExpression.Select(x =&gt; x.ExpressionName).ToArray();
    var JoinExp = lstProduct1.Join(lstProduct2, Fields);
    bool IsSuccess = true;// CompareTwoLists(lstProduct1, lstProduct2, (listProductx1, listProductx2) =&gt; JoinExp.Any());

    return IsSuccess;
}
</code></pre>

<p>When I compile the above code; I am getting error on below line </p>

<pre><code>var JoinExp = lstProduct1.Join(lstProduct2, Fields);
</code></pre>

<p>Error is</p>

<blockquote>
  <p>Error 1   The type arguments for method
  'AP.Classes.ListComparison.Join(System.Collections.Generic.IEnumerable,
  System.Collections.Generic.IEnumerable,
  System.Collections.Generic.IEnumerable)' cannot be inferred
  from the usage. Try specifying the type arguments
  explicitly.   D:\Workshop\Ap\Classes\DuplicateValidator.cs</p>
</blockquote>

<p>How to solve this error? I am creating a List comparison tool.</p>