Saturday, July 12, 2008

DELEGATES

What is Delegation?

A delegate acts like a strongly type function pointer. Delegates can invoke the methods that they reference without making explicit calls to those methods.
Delegate is an entity that is entr...

Function pointer, which is used to pass the function as a paramenter

What is Multicast delegates?

Have tob declare the delegate array and have to pass as the parameter

What is Event - Delegate? clear syntax for writing a event delegate

The event keyword lets you specify a delegate that will be called upon the occurrence of some "event" in your code. The delegate can have one or more associated methods that will be called when your code indicates that the event has occurred. An event in one program can be made available to other programs that target the .NET Framework Common Language Runtime.

// keyword_delegate.cs
// delegate declaration
delegate void MyDelegate(int i);
class Program
{
public static void Main()
{
TakesADelegate(new MyDelegate(DelegateFunction));
}
public static void TakesADelegate(MyDelegate SomeFunction)
{
SomeFunction(21);
}
public static void DelegateFunction(int i)
{
System.Console.WriteLine("Called by delegate with number: {0}.", i);
}
}

What is Asynchronous call and how it can be implemented using delegates?

One of the many great features of the .NET Framework is that it has asynchronous infrastructure built in. In .NET you can call any method asynchronously by defining a delegate for the method and calling the delegate's asynchronous methods. This is beneficial to your application because when a synchronous call is made, the calling thread is blocked until the method completes whereas an asynchronous call is made on a different thread, and this allows the original thread to continue its work while the asynchronous call is in progress.This article explains delegates in .NET and how to use them to perform asynchronous calls, eliminating age-old threading problems.

http://msdn.microsoft.com/msdnmag/issues/01/08/Async/

How to create events for a control? What is custom events? How to create it?

http://www.15seconds.com/Issue/031023.htm?voteresult=5

What's a delegate?

A delegate object encapsulates a reference to a method. In C++ they were referred to as function pointers.

What's a multicast delegate?

It's a delegate that points to and eventually fires off several methods.

What are delegates?where are they used ?

A delegate defines a reference type that can be used to encapsulate a method with a specific signature. A delegate instance encapsulates a static or an instance method. Delegates are roughly similar to function pointers in C++; however, delegates are type-safe and secure.

Can you change the value of a variable while debugging a C# application?

Yes, if you are debugging via Visual Studio.NET, just go to Immediate window.

No comments: