Asp.net programming we consider all important topic for knowledge about controls,web Services, JSON, Ajax, database, and interview related Question. In this Asp.net and sql server tutorial blog we give many examples of jquery as like How Play YouTube Video in Your Asp.net Website by URL, How to Play YouTube Videos in Asp.net by using Jquery , Jquery Change div background on mouseover in asp.net , JQuery UI Datepicker (Calendar) etc.

Saturday, August 22, 2015

What is Delegates in C#, how to declare and use C# Delegates

What is Delegates in C#, how to declare and use C# Delegates:

Delegates in C#, how to declare:

In other programming language like C++, Pascal gives the facility of function pointer. Similar in C#(object-oriented language) use delegate. C# delegate enable encapsulate both an object and instance and a method. A delegate declaration defines a class that is derived from the class System.Delegate. A delegate instance encapsulates an invocations list, which is a list one or more method, each of which is referred to as callable entity.




A delegate defines a reference type that can be used to encapsulate a method with a specific signature.

C# delegate Life cycle:

The life cycle of C# delegate is
  • Declaration
  • Instantiation
  • INVACATION


C# delegate Declarations:

Delegate declaration is a type declaration that declare a new delegate type .

SYNTAX OF DELEGATE DECLARATION :

[modifier] delegate [return type][identifier]( formal parameters)

EXAMPLE OF DLEGATE:

Public delegate int MYFirstDelegate(int i)

DELEGATE –MODIFIER:

  • new
  • public
  • protected
  • internal
  • private


No comments:

Post a Comment