将函数作为参数传递 (CS1503)

Passing Function as Parameter ( CS1503 )

尝试创建一个函数,我可以在其中传递不同的函数来测试 运行 并测量它花费了多长时间。现在的主要问题是我什至不能通过函数..

public static void Main(string[] args)
        {
            string Inputs = Console.ReadLine();
            List<int> UnSorted = new List<int>();

            for (int i = 0; i < Inputs.Split(' ').Count(); i++)
            {
                UnSorted.Add(int.Parse(Inputs.Split(' ')[i]));
            }

            CheckTimeOfSorting(SortWithTwoLoops); // <--- Error ( Can't convert from method group to Func<List<int>>)

            Console.WriteLine(String.Join(" ", UnSorted));
        }

        public static void CheckTimeOfSorting(Func<List<int>> SortingFunc)
        {

        }

        public static List<int> SortWithTwoLoops(List<int> UnSorted)
        {
            List<int> Result = UnSorted;
            for (int i = 0; i < Result.Count; i++)
            {
                for (int j = i + 1; j < Result.Count; j++)
                {
                    if (Result[i] > Result[j])
                    {
                        int temp1 = Result[i];
                        int temp2 = Result[j];

                        Result[i] = temp2;
                        Result[j] = temp1;
                    }
                }
            }
            return Result;
        }
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;

namespace NewVSFunction
{
    public static class MykytaHttpFunction
    {
        public static void Main(string[] args)
        {
            string Inputs = Console.ReadLine();
            List<int> UnSorted = new List<int>();

            for (int i = 0; i < Inputs.Split(' ').Count(); i++)
            {
                UnSorted.Add(int.Parse(Inputs.Split(' ')[i]));
            }

            CheckTimeOfSorting(SortWithTwoLoops); // <--- Error ( Can't convert from method group to Func<List<int>>)

            Console.WriteLine(String.Join(" ", UnSorted));
        }

        public static void CheckTimeOfSorting(Func<List<int>, List<int>> SortingFunc)
        {

        }

        public static List<int> SortWithTwoLoops(List<int> UnSorted)
        {
            List<int> Result = UnSorted;
            for (int i = 0; i < Result.Count; i++)
            {
                for (int j = i + 1; j < Result.Count; j++)
                {
                    if (Result[i] > Result[j])
                    {
                        int temp1 = Result[i];
                        int temp2 = Result[j];

                        Result[i] = temp2;
                        Result[j] = temp1;
                    }
                }
            }
            return Result;
        }
    }
}

您需要在 Func 中为 return 指定一个类型,请参阅更新的代码