Which of the following is the correct way to call the function abc() of the given class in the following C# code?
class csharp
{
public int abc(int a)
{
Console.WriteLine("A:Just do it!");
return 0;
}
}
class csharp
{
public int abc(int a)
{
Console.WriteLine("A:Just do it!");
return 0;
}
}A.
delegate void del(int a);
csharp s = new csharp();
del d = new del(ref s.abc);
d(10);B.
csharp s = new csharp();
delegate void d = new del(ref abc);
d(10);C.
delegate int del(int a);
del d;
csharp s = new csharp();
d = new del(ref s.fun);
d(10);D. none of the mentioned
Answer: Option C
Related Questions on Delegates and Events in C Sharp
What is the purpose of the GetInvocationList() method associated with delegates in C#?
A. Removes a delegate from the current delegate
B. Adds a new delegate to the current delegate
C. Invokes all the delegates bound to the current delegate
D. Retrieves an array of delegates bound to the current delegate
What is a callback function in the context of delegates and events in C#?
A. A function that is called when an event is raised
B. A function that is called to subscribe to an event
C. A function that is called to unsubscribe from an event
D. A function that is called to handle an event
A. Func
B. Predicate
C. Action
D. EventHandler

Join The Discussion