multidimensional array - C# trouble passing inline code -
hey know there lot of questions contain answer need, i'm having hard time sifting between func/action/delegate/lambda, , javascript guy feels needlessly complex.
i'm working 2d arrays , write method accepts int width, int height, , form of inline code called every x/y pair. point avoid bugs , time writing nested loop on , over. i'm unsure proper type of inline code use, or looks like. i've tried bunch of combos can't make work out.
what signature should use on method, , how call that?
i use action type parameter, , lambda when calling:
foreachpair(5, 5, (x, y) => { console.write(x + "," + y); }); public void foreachpair(int width, int height, action<int, int> callback) { (int = 0; < width; i++) { (int j = 0; j < height; j++) { callback(i, j); } } }
Comments
Post a Comment