Can't get Array.Sort(Array, Array) to work

chairmanMalchairmanMal USMember ✭✭

Why does this generate the compile error :
Error CS1502: The best overloaded method match for `System.Array.Sort(System.Array, System.Collections.IComparer)' has some invalid arguments (CS1502) ???

The Xamarin documentation shows that System.Array has a Sort (Array, Array) method overload for Sort.

Chris

using System;

namespace pfb.BusinessLogic
{
public class TestArray
{
int[] items = {25, 20,15,10, 5};
double[] keys = {0.25, 1.5, 0.75, 8.0, 0.1};

    public TestArray ()
    {

        Array.Sort(keys, items);

    }
}

}

Tagged:

Best Answer

Answers

  • mridonimridoni ITMember ✭✭

    What version are you using? This compiles flawlessly on Mono 4.2.1 in Linux, Xamarin 5.10.2 and VS 2015. I slightly reworked the code but did not touch the Array.Sort method call.

    using System;
    
    namespace pfb.BusinessLogic
    {
        public class TestArray
        {
            static int[] items = {25, 20,15,10, 5};
            static double[] keys = {0.25, 1.5, 0.75, 8.0, 0.1};
    
            public static void Main()
            {
                Array.Sort(keys, items);
            }
    
        }
    }
    
Sign In or Register to comment.