using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace USE_DELEGATE
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
//Create delegate
public delegate void delegatemessageshow(string msg);
private void Form1_Load(object sender, EventArgs e)
{
}
// Create method same return type of delegate it must
public void showmessage(string s)
{
MessageBox.Show(s);
}
private void btndel_Click(object sender, EventArgs e)
{
// Create instance of delegate and call method
delegatemessageshow dlm = new delegatemessageshow(showmessage);
dlm("Hi Delegate");
}
}
}
Comments
Post a Comment