Skip to content

Commit

Permalink
## various operations using same delegate and different lambda
Browse files Browse the repository at this point in the history
  • Loading branch information
nahiandev committed Dec 5, 2024
1 parent 3ba778b commit c3a8111
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions DomeTrain/Program.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
using System.Text;

namespace DomeTrain
namespace DomeTrain
{
class Program
{
static void Main()
{
DoStuff(7, 5, (x, y) => x * y);
}
{
DoStuff(1, 2, (x, y) => x + y);

private static void DoStuff(int x, int y, Calculate math_ops) => Console.WriteLine(math_ops(x, y));
DoStuff(3, 4, (x, y) => x * y);

DoStuff(7, 6, (x, y) => x * y);

DoStuff(7, 5, (x, y) => Convert.ToInt32(string.Join("", [x, y])));
}

private static void DoStuff(int x, int y, Calculate math_ops) => Console.WriteLine(math_ops(x, y));
delegate int Calculate(int x, int y);
}
}

0 comments on commit c3a8111

Please sign in to comment.