The interviewer asked me that he had a heavy class with a number of methods. At the moment, he should have only one method.
He asked me if C # delegates can call me this method without instantiating the class?
And he said that delegates can help us this way.
I was looking for him. I tried to run it on VS, but I think I will need to initialize the class.
Take a look at this snippet -
public class HomeController : Controller
{
public ActionResult test()
{
NumberChanger nc1 = new NumberChanger( );
return View();
}
}
public delegate int NumberChanger(int n, int m);
public class abc
{
int a;
int b;
public int sum(int a, int b) {
return a + b;
}
}
source
share