Sunday, 3 December 2017

C# Program to Display Results using Delegates


Code:

using System;
public class example
{
    public delegate int DelegateHandler(int a, int b);
    static void Main(string[] args)
    {
        Results Results = new Results();
        DelegateHandler sum = new DelegateHandler(Results.sum);
        int result = sum(50, 20);
        Console.WriteLine("Result is: " + result);
        Console.ReadLine();
    }
}

public class Results
{
    public int sum(int a, int b)
    {
        return a + b;
    }
}


Output:

Result is: 70


More C# Programs:





















100+ Best Home Decoration Ideas For Christmas Day 2019 To Make Home Beautiful

Best gifts for Christmas Day | Greeting cards for Christmas Day | Gift your children a new gift on Christmas day This Christmas d...