Choose the correct way to call subroutine fun() of the sample class?
class a
{
public void x(int p, double k)
{
Console.WriteLine("k : csharp!");
}
}
class a
{
public void x(int p, double k)
{
Console.WriteLine("k : csharp!");
}
}A.
delegate void del(int i);
x s = new x();
del d = new del(ref s.x);
d(8, 2.2f);B.
delegate void del(int p, double k);
del d;
x s = new x();
d = new del(ref s.x);
d(8, 2.2f);C.
x s = new x();
delegate void d = new del(ref x);
d(8, 2.2f);D. all of the mentioned
Answer: Option B
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