C# Programming - Delegates - Discussion

Discussion Forum : Delegates - General Questions (Q.No. 5)
5.
Which of the following is the correct way to call the function MyFun() of the Sample class given below?
class Sample
{
    public int MyFun(int i)
    {
        Console.WriteLine("Welcome to IndiaBIX.com !" );
        return 0;
    }
}
delegate void del(int i);
Sample s = new Sample();
deld = new del(ref s.MyFun);
d(10);
delegate int del(int i);
Sample s = new Sample(.);
del = new delegate(ref MyFun);
del(10);
Sample s = new Sample();
delegate void del = new delegate(ref MyFun);
del(10);
delegate int del(int i);
del d;
Sample s = new Sample();
d = new del(ref s.MyFun);
d(10);
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
2 comments Page 1 of 1.

Aaron T said:   10 years ago
Remove 'ref'.

Anubhav singh said:   10 years ago
What is this "ref" doing here?

Post your comments here:

Your comments will be displayed after verification.