About delegates ?

Answer Posted / naren

1. Delegates holds reference to a method
2. Delegates are objects which points towards a function
which matches its signature
3. Delegates are reference type used to encapsulate method
with specific signature
4. Delegates are typesafe and secure

//declaring a delegate

delegate void SampleDelegate(string message)

//declaring delegate with same signature

static void SampleDelegateMethod(string message)
{
console.writeline(message);
}

//creating delegate method

SampleDelegate d1 = new SampleDelegateMethod();

//invoking method

d1(message);

Is This Answer Correct ?    10 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between localization and globalization?

663


Describe Segmentation With Paging?

713


Which namespace is used by ado.net?

637


Explain swagger components.

656


What is the full meaning of asp.net?

602






How to create discussion forum in asp.net mvc? : Asp.Net MVC

625


Explain how can we inherit a static variable?

620


explain code with multi inhertance

1728


Explain managed code an un-managed code.

679


What is the parent class of all the web server control?

581


What are the ways of preserving data on a Web Form in ASP.NET?

711


Explain the steps needed to be performed in order to create an animation in xaml?

647


What is the use of express session?

627


What is the use of HttpHandlers? When to use this?

713


What do you understand by aggregate dependency?

703