fork download
  1. using System;
  2.  
  3. public class Kublies
  4. {
  5. Func<int[], int[], int> cbfunc;
  6.  
  7. public void register_cb(Func<int[], int[], int> cb)
  8. {
  9. cbfunc = cb;
  10. }
  11.  
  12. public int call_cb(int[] dat_in)
  13. {
  14. int res;
  15. int[] xform = new int[dat_in.Length];
  16.  
  17. Console.Write("In: [");
  18.  
  19. foreach (int j in dat_in)
  20. Console.Write(" " + j.ToString());
  21.  
  22. res = cbfunc(dat_in, xform);
  23.  
  24. Console.WriteLine("]");
  25. Console.Write("Xform: [");
  26.  
  27. foreach (int j in xform)
  28. Console.Write(" " + j.ToString());
  29.  
  30. Console.WriteLine("]");
  31.  
  32. return res;
  33. }
  34. }
  35.  
  36. public class Test
  37. {
  38. private int xfandsum(int[] din, int[] dout)
  39. {
  40. int j;
  41. int res = 0;
  42.  
  43. for (j = 0; j < din.Length; j++)
  44. {
  45. res += din[j];
  46. dout[j] = din[j] * 2 + 3;
  47. }
  48.  
  49. return res;
  50. }
  51.  
  52. public static void Main()
  53. {
  54. int val;
  55. Test tes = new Test();
  56. Kublies kub = new Kublies();
  57. int[] testdata = {3, 9, 7, 1, 2, 8, 4};
  58.  
  59. kub.register_cb(tes.xfandsum);
  60. val = kub.call_cb(testdata);
  61.  
  62. Console.WriteLine("Result: " + val.ToString());
  63. }
  64. }
  65.  
Success #stdin #stdout 0.07s 28648KB
stdin
Standard input is empty
stdout
In:    [ 3 9 7 1 2 8 4]
Xform: [ 9 21 17 5 7 19 11]
Result: 34