using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Delgates_Ex1 { public delegate void ExampleDelgate(int x, int y); class Democlass { public void Add(int x, int y) { Console.WriteLine(x+y); } } class Program { static void Main(string[] args) { Democlass d = new Democlass(); ExampleDelgate e1 = new ExampleDelgate(d.Add); e1(20, 10); } } }
static void Main(string[] args) { Democlass d = new Democlass(); ExampleDelgate e1 = new ExampleDelgate(d.Add); ExampleDelgate e2 = delegate(int x, int y){ Console.WriteLine(x+y);}; // anonymous method e1(20, 10); e2(20, 10); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)