using System;
using System.Windows.Forms;
namespace DelegatesTesting
{
public partial class DelegatesTest : Form
{
public DelegatesTest()
{
InitializeComponent();
}
//Delegate Declaration
public delegate int PointtoAddFunction(int i, int j);
private void btnSubmit_Click(object sender, EventArgs e)
{
//Point the Delegate object with Method
PointtoAddFunction handler = AddFunction;
//Invoke the Method
MessageBox.Show(handler(10, 12).ToString());
}
//Method
public int AddFunction(int i, int j)
{
return i + j;
}
}
}
No comments:
Post a Comment
Comments Welcome