Symbol not found on Comparer<T>

99 views Asked by At

I am using .net framework 4.0

For some reason visual studio is highlighting a method as red and the tool tip has:

'Cannot resolve symbol 'Create''

I can't see why the compiler would complain. It is a static method on a generic .net framework class:

System.Collections.Generic.Comparer<string>.Create((x,y)=>x.CompareTo(y));

The method Create exists on the Comparer class. The visual studio drop down options for static methods/properties only shows me the static property 'Default' on the class Comparer and I don't see why it doesn't show the static Create method.

Here is the microsoft code for that class:

public abstract class Comparer<T> : IComparer, IComparer<T>
{
    public static Comparer<T> Create(Comparison<T> comparison)
    {
        Contract.Ensures(Contract.Result<Comparer<T>>() != null);

        if (comparison == null)
            throw new ArgumentNullException("comparison");

        return new ComparisonComparer<T>(comparison);
    }
1

There are 1 answers

0
Stuart On

ok - thanks to John Saunders - I looked on the microsoft documentation and the create method was introduced in .net 4.5.

I am not sure why visual studio shows me the .net 4.5 version of the code when the project is set to 4.0