4 August 2013

Delegates Example in C#

//Delegates Example in C#

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

Consistency level in Azure cosmos db

 Consistency level in Azure cosmos db Azure Cosmos DB offers five well-defined consistency levels to provide developers with the flexibility...