What is Func, how and when is it used

前端 未结 8 1829
悲哀的现实
悲哀的现实 2020-11-27 10:53

What is Func<> and what is it used for?

8条回答
  •  我在风中等你
    2020-11-27 11:12

    Func is a predefined delegate type for a method that returns some value of the type T.

    In other words, you can use this type to reference a method that returns some value of T. E.g.

    public static string GetMessage() { return "Hello world"; }
    

    may be referenced like this

    Func f = GetMessage;
    

提交回复
热议问题