Articles → CSHARP → Func Delegate In C#
Func Delegate In C#
Purpose
Example
using System;
namespace ConsoleApp2 {
class Program {
static void Main(string[] args) {
Program program = new Program();
Func <string, string> messageDelegate = program.Greet;
Console.WriteLine(messageDelegate("Gyan"));
Console.ReadLine();
}
public string Greet(string name) {
return string.Format("Hello {0}", name);
}
}
}
Output
Click to Enlarge