Skip to content

Commit c799a8e

Browse files
committed
added c# implementation
1 parent 355a896 commit c799a8e

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

fp.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using System;
2+
3+
class FunctionPointerDemo
4+
{
5+
static int Increment(int n)
6+
{
7+
return n + 1;
8+
}
9+
10+
static void MyObjective(int[] arr, Func<int, int> F)
11+
{
12+
for (int i = 0; i < arr.Length; ++i)
13+
arr[i] = F(arr[i]);
14+
}
15+
16+
static void Main(string[] args)
17+
{
18+
int[] arr = {0, 1, 2, 3, 4};
19+
MyObjective(arr, Increment);
20+
21+
for (int i = 0; i < arr.Length; ++i)
22+
Console.Write(arr[i] + " ");
23+
}
24+
}

0 commit comments

Comments
 (0)