1.Func<T1, TResult> 用法以及含义
   封装一个具有T参数并返回 TResult 参数指定的类型值的方法。如果不需要使用返回TResult 请使用Action<T>
2.如果要使用需要引用System.Core
3.语法格式为:
   public delegate TResult Func<T1, TResult>(
    T1 arg1,
     )

类型参数说明

T1
此委托封装的方法的第一个参数类型。
TResult

此委托封装的方法的返回值类型。

using
System; delegate string[] ExtractMethod(string stringToManipulate, int maximum); public class DelegateExample { public static void Main() { // Instantiate delegate to reference ExtractWords method ExtractMethod extractMeth = ExtractWords; string title = "The Scarlet Letter"; // Use delegate instance to call ExtractWords method and display result foreach (string word in extractMeth(title, 5)) Console.WriteLine(word); } private static string[] ExtractWords(string phrase, int limit) { char[] delimiters = new char[] {' '}; if (limit > 0) return phrase.Split(delimiters, limit); else return phrase.Split(delimiters); } }

 

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-02-23
  • 2021-07-28
  • 2022-01-18
  • 2021-10-29
  • 2021-08-15
猜你喜欢
  • 2022-12-23
  • 2021-06-21
  • 2021-09-13
  • 2021-07-20
  • 2021-09-18
相关资源
相似解决方案