Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Program {
- delegate T BinaryOperator<T>(T opA, T opB);
- static int Add(int a, int b) {
- return a + b;
- }
- static int Subtract(int a, int b) {
- return a - b;
- }
- static void Main(string[] args) {
- BinaryOperator<int>[] operators = new BinaryOperator<int>[2];
- operators[0] = Add;
- operators[1] = Subtract;
- Console.WriteLine(operators[0](2, 4));
- Console.WriteLine(operators[1](3, 5));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement