c# - Dynamically setting value on array of pointers to integers -
I have a multi-dimensional array of pointers for the integer (unknown rank) passing in my function:
Public Unsecured Static Zero MyMethod (Array source, ...) {//}}Points are being constructed outside the multidimensional arrays method And has been passed. Here's an example:
int * [,,,] testArray = new int * [10,10,5,5]; MyMethod (testArray);
How can I set a value on an order-time-calculation index in the array? Array.SetValue (...) works perfectly fine for non-punter array, but refuses to work for my int * array using the reflector, I think SetValue is called InternalSetValue , Which takes an object for the value, but it has been marked as an Exxon and I can not see the implementation. I took a shot in the dark and tried to pass in the boxing indicator, but no luck.
This works:
Unsafe Static Zero MyMethod (int ** array) {array [10] = (int *) 0xdeadbeef; } Private static vulnerable Zero main () {int * [,,,] array = new int * [10, 10, 10, 10]; Fixed (int ** ptr = array) {MyMethod (ptr); } Int * x = array [0, 0, 1, 0]; // <== 0xdeadbeef}
Does it help?
Questions from experts: Is it wrong to believe that the array is continuously allocated in memory?
Comments
Post a Comment