53.Delegate as class data member
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace delegate_as_class_data_member
{
public delegate void Delgate_op(string msg);
class delegate_class
{
public static void wlc(string msg)
{
Console.WriteLine("Welcome " + msg);
}
public static void Bye(string msg)
{
Console.WriteLine("Bye " + msg);
}
}
class Program
{
static void Main(string[] args)
{
Delgate_op obj = new Delgate_op(delegate_class.wlc);
obj("Milan");
obj = delegate_class.Bye;
obj("Milan");
Console.Read();
}
}
}
OUTPUT:
Welcome Milan
Bye Milan
Comments
Post a Comment