sample code
This commit is contained in:
28
MySolution/ConsoleApp/Samples/CalculateSample.cs
Normal file
28
MySolution/ConsoleApp/Samples/CalculateSample.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
|
||||
namespace Samples
|
||||
{
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user