Technology Guruu

  • Home
  • Site Info
    • About Us
    • Disclaimer
    • Privacy Polacy
  • Home
  • Digital Marketing
    • SEO
    • SMM
    • SEM
  • Quotes
  • Technical
  • Java
  • .Net
    • C#.Net
    • ASP.Net
  • Keychains

Tuesday, 10 October 2017

Brief description about Delegates

 Akansha     16:30:00     TechnicalQuestions     No comments   

Introduction about delegates and why delegates are came the main purpose of delegates how to useful and what are the advantages and disadvantages and types of delegates all are provided in this article.

Best Tutorial about Delegates

brief introduction about delegates
Introduction

Delegates Introduction

  • Delegates are similar like C++ function pointers
  • To define we have to use delegate keyword,delegate are reference types.
  • delegate can hold the address of a function,using delegate object we can invoke a method without using method name.

Delegates are 2 types

1.Single caste Delegate

It can hold address of a single method

2.Multi Cast delegate:

  • It can  hold adresses of multiple methods
  • using multicast delegate we can ivoke multiple methods with a single call.

Implementation of delegate concept can be divided into following steps
Step1: Defining a class
step2: Defining a method
Step3: Defining a delegate
<Syntax>
<accessmodifier>delegate<returntype><delegatename>(<type><arg1>,<type><arg2>);
step4:creating object for delegateand initializing the method name
<delegatename><delegate objname>=new <delegatename>(<methodname>);
Step5: invokin the method by using delegate object
<delegate ojjname()>;
delegate are called as type function pointers because delegate declaration should follow the mathod declaration which is holding by the delegate object that means method return type and signature should be same for delegate.
Note:
Delegate can hold the address of static methods as well as instance methods.
Example to invoke instance methods by using delegate object(single cast delegate)
namespace singlecastDelegateex1
{
class calculate
{
internal int add(int a,int b)
{
return a+b;
}

}
internal delegate int Mydelegate(int x,int y);
class Program
{
void main()
{
calculate obj=new calculate();
MyDelegate delobj=new MyDelegate(obj.add);
int res=delobj(10,5);
console.WriteLine("addition result is :"+res);
console.ReadLine();
}
}
}
Friends you like my post please share to your friends through Facebook,Twitter,Google+.
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg
Email ThisBlogThis!Share to XShare to Facebook
Older Post Home

0 comments:

Post a Comment

Popular Posts

  • Missing My Friend Quotes : Friendship Day Quotes 2017
    Friends today my article about missing friends and moments with them. Here you are seen the best friendship quotes and some  feelings when...
  • Love Failure Quotes and Sad valentines day Quotes
    We Love Someone is a easy process sometime takes long time to love someone love others within short period but anyway always love dependin...
  • Brief description about Delegates
    Introduction about delegates and why delegates are came the main purpose of delegates how to useful and what are the advantages and disadv...
  • Na Tanu Samjhawan Ki Song lyrics
    Na Tanu Samjhawan Ki Song Lyrics With English Translation Movie : Humpty Sharma ki Dulhaniya Song : Samjhawan Song Singer : Arijit ...
  • Detail Introduction about C#.Net
    Brief Introduction about C#.Net  Introduction C#.Net is the one of the Programming Language the .Net Framework also contains ano...
  • Wonderful sayings about Life.
    I Believe Follow  Things(Life Quotes) I Believe I believe: ********** Believe in Life ********** That we don't have to chan...
  • Brief Description about Multicast Delegate
    Multicast delegate is an extension of normal delegate. It helps you to point more than one method at a single moment of time. Multicast ...
  • Top 10 valentine's day Quotes and Greetings wishes
    All Lovers have Anxiety in Valentines day because it is a festival to all lovers in these they enjoy a lot and celebrate the Valentine...
  • Brief description about properties
    Properties in C#.Net Properties Property is a member of a class which we will use to assign the value to a variable as well as whi...
  • Valentines day poems and wishes or Quotes
    A friendship that like love is warm; A love like friendship, steady.we are having the most difference between love and Friendship you mus...

Categories

  • Entertainment (67)
  • TechnicalQuestions (58)
  • Quotes (11)
  • C#.Net (8)
  • Java (8)
  • ValentinesDay (4)
  • SEO (3)
  • Home
  • About Us
  • Disclaimer
  • Privacy Policy
  • Sitemap

Copyright © 2015-2017 Good Friends 5.All Rights Reserved• And Our Sitemap • All Logos and Trademark Belongs To Their Respective Owners•