Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu
Showing posts with label Beginner Delegate program. Show all posts
Showing posts with label Beginner Delegate program. Show all posts

Wednesday, August 24, 2011

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 ...