lambda表达式用于委托方法


public static void Main()
   {
      // Instantiate delegate to reference UppercaseString method
      Func<string, string> convertMethod = UppercaseString;
      string name = "Dakota";
      // Use delegate instance to call UppercaseString method
      Console.WriteLine(convertMethod(name));
   }

   private static string UppercaseString(string inputString)
   {
      return inputString.ToUpper();
   }

  public TResult CallService<TServiceContract, TResult>(Func<TServiceContract, TResult> func) // func是委托形参
        {
            return ServiceHelper.CallService(func);
        }
 if(CallService<ITrafficCenterService, bool>(f => f.AskingCar(condition, out msg))) // 调用表达式用Lambda表达式作为委托方法


猜你喜欢

转载自blog.csdn.net/softuse/article/details/79368542