C# Programming - Delegates - Discussion

Discussion Forum : Delegates - General Questions (Q.No. 1)
1.
Which of the following statements is incorrect about delegate?
Delegates are reference types.
Delegates are object oriented.
Delegates are type-safe.
Delegates serve the same purpose as function pointers in C and pointers to member function operators in C++.
Only one method can be called using a delegate.
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
21 comments Page 1 of 3.

Alazar said:   8 years ago
D can also be an answer! A delegate in C# is similar to a function pointer in C or C++.

Using a delegate allows the programmer to encapsulate a reference to a method inside a delegate object. The delegate object can then be passed to code which can call the referenced method, without having to know at compile time which method will be invoked.

Ravindar Nath Mishra said:   1 decade ago
We can call multiple method multicast delegate. Each delegate object are created, by default maintains an invocation list, which is the list of methods that are encapsulated into the delegate object. The invocation list of multicast delegates contains multiple methods that are invoked in the order they were added.

Sean Johnson said:   1 decade ago
There are two types of delegates: Unicast and Multicast delegates.

In Unicast ,at time only one method is associated with single cast delegate.

In Multicast delegate, at a time two or more methods is associated with delegates. i.e a delegate is refrencing to two or more methods.

So the anwer is E.

Vishwadeep said:   1 decade ago
Synchronous: simultaneously process is Main Intention of Delegates.

If a delegate has do not return any value, it is a multicast delegate that can invoke multiple methods.

Invoke all the delegates with the combined delegates DynamicInvoke property.

Delegates are invoked in the order they are added.

Sunil Kumar Singh said:   1 decade ago
In C and C++ we use the function pointer in this a function hold the reference of another function which is similar as of the function pointer. Since C# does not support the pointer so we use the delegate here in place of function pointer.

Shahbaz chaudhary said:   1 decade ago
But correct answer is show delegate can only one method called but everybody say delegate can be called more than one method at same time. So please give me correct answer i am confuse of this query and I don't know more about delegate.

Santosh kitta said:   1 decade ago
Delegate is an a object that can to method it is allow you to dynamically change the reference to method in a class,
Delegate is reference type variable which holds reference to method. This method can be change at run time.

Bindu said:   1 decade ago
It is possible for a delegate to call more than one function at a time when all the methods that point to that delegate has same method signature, and += operator is used to append method references to the delegate.

Ashwani kumar said:   1 decade ago
We are calling more than one method by using unicast delegate also but the method name should be same. Delegate is similar function pointer. C# does not support the pointer but delegate is use in function pointer.

Jeet said:   1 decade ago
Yes but delegates is much more tan just a function pointer as it is in c and cpp, moreover delegates are much more heavy as compared to the function pointers in c and cpp.


Post your comments here:

Your comments will be displayed after verification.