What is delegate? What is its real time usage? Give C# code to demonstrate delegate.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public delegate double doubleDelegate(double w,double h);
namespace delegateSimpleExample
{
 public class delegateClass
 {
  public static double getArea(double w,double h)
  {
   return w*h*0.5;
  }
 }
 public class delegateSimpleExampleDemo
 {
  public static void Main(String[] args)
  {
   Console.WriteLine("C# code to demonstrate delegate");
   doubleDelegate delegateObject = new doubleDelegate(delegateClass.getArea);
   Console.WrileLine("Area of Triangle is : " + delegateObject(15,20));
   Console.ReadLine();
  }
 }
}

Related Posts Plugin for WordPress, Blogger...

Engineering material

GTU IDP/ UDP PROJECT

GTU IDP/ UDP PROJECT

Patel free software download

  © Blogger templates The Professional Template by Ourblogtemplates.com 2008

Back to TOP