For Asp.net Training with C# Click Here
Written By:-Isha Malhotra
Email:-malhotra.isha3388@gmail.com
How To Use Delegate and Its Type
Delegate is
a reference type which refer to a method. Delegates object hold the reference
of method of same signature. We invoke the method through delegate and this can
be determined at the runtime instead of compile time.
Note:-delegates can invoke both
static and non static method.
Syntax of delegate:-
Public
delegate return_typ delegate_name(parameters);
For Example:-
For non static method
Suppose we
are creating a class which contains some method for sum, div, sub and mul of
two numbers. We create delegate to hold the reference of these methods.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;