public void anony() { CalculateSimpleInterest d1 = delegate(int principle, int rate, int time) { int simpleInterest = principle * rate * time; Console.WriteLine("Anonymous Simple interest = {0}", simpleInterest); }; d1(10, 10, 2); }
public void CallDelegates(DelegateExample d) { Console.WriteLine("Using Instance Method"); Console.WriteLine("Enter Principle, Rate of Interest & Number of Years Respectively :"); double principle = Convert.ToDouble(Console.ReadLine()); double ROI = Convert.ToDouble(Console.ReadLine()); double years = Convert.ToDouble(Console.ReadLine()); //Instance Method CalculateSimpleInterest d0 = new CalculateSimpleInterest(d.GetTotalInterest); d0 += new CalculateSimpleInterest(d.GetInterestRatePerYear); d0(principle, ROI, years); }