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

AI Evolution Explained: GenAI vs LLMs vs AI Agents vs Agentic AI vs Intelligent AI

Artificial Intelligence (AI) is one of the most exciting technologies in our world today. But the terms that come with it like GenAI, LLMs, ...

MSDEVBUILD - English Channel

MSDEVBUILD - Tamil Channel

Popular Posts