2023-05-11 11:47:56 +09:00
|
|
|
using System;
|
|
|
|
|
2023-05-11 13:56:53 +09:00
|
|
|
namespace Samples.Calculate
|
2023-05-11 11:47:56 +09:00
|
|
|
{
|
|
|
|
class CalculateSample
|
|
|
|
{
|
|
|
|
private delegate int Calculate(int x, int y);
|
|
|
|
|
|
|
|
public static int Add(int x, int y)
|
|
|
|
{
|
|
|
|
return x + y;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static int Subtract(int x, int y)
|
|
|
|
{
|
|
|
|
return x - y;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void Sample()
|
|
|
|
{
|
|
|
|
Calculate calc1 = Add;
|
|
|
|
Calculate calc2 = Subtract;
|
|
|
|
|
|
|
|
Console.WriteLine(calc1(10, 5));
|
|
|
|
Console.WriteLine(calc2(10, 5));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|