Hi,
I came across a question which made me confused. What is the use of having "ref" before s.MyFun in this case. I tried to remove it and it still works.
I understand the reason for putting it before a variable that the content can be changed subsequently. What is the use of this one ? the function content will not be changed.
Code
class SampleCode
{Code
public void MyFun(int i, Single j)Code
{Code
Console.WriteLine("Welcome to IndiaBIX !");Code
}Code
}Code
delegate void del(int i, Single j);Code
del d; Sample s = new Sample();Code
d = new del(ref s.MyFun);Code
d(10, 1.1f);
Nanhe SiddiqueRank #1,103 · 1.7K reputationPosted May 19, 2015, 8:39 PM EDT