Beginner Delegate program

Add Two Number Delegate Program

public delegate int AddTwoNumberDel(int fvalue, int svalue);

private void btnClick_Click(object sender, EventArgs e)
{
AddTwoNumberDel AT = Addnumber; // create delegate instance
//is shorthand for
//AddTwoNumberDel AT = new AddTwoNumberDel(Addnumber);
int a = Convert.ToInt16(txtfvalue.Text);
int b = Convert.ToInt16(txtsvalue.Text);
txtresult.Text = AT(a, b).ToString(); // invoke Method
//is shorthand for
//txtresult.Text = AT.Invoke(a, b).ToString();
}

public int Addnumber(int fvalue, int svalue)
{
return fvalue + svalue;
}

Note:

Copy and past your VS Editor it will Work... Do you want sample application mail me ...

0 Comments

Featured Post

Understanding about Azure Region, Geographies, Availability Zones and Region Pairs

Introduction Microsoft Azure services are available in 53 regions around the world, with plans announced for 7 additional regions and 140+ a...

Subscribe to the FREE Weekly Newsletter to receive all the latest Microsoft Azure, AI, Xamarin

Popular Posts