adplus-dvertising
frame-decoration

Question

Which of the following is the correct way to call the function abc() of the given class csharp given below?
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

Posted under C# programming

Answer: (c).delegate int del(int a);
del d;
csharp s = new csharp();
d = new del(ref s.fun);
d(10);

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. Which of the following is the correct way to call the function abc() of the given class csharp given below?