I rewrite code from C to C #. Faced the following problem.
Here's the code for si.
int right[2 * par - 1]; int left[2 * par - 1]; ... void func() { int *p; // some code if (k & mask) p = &right[*p]; else p = &left[*p]; } And here is my version in C #.
int[] right = new int[2 * par - 1]; int[] right = new int[2 * par - 1]; ... unsafe void func() { int *p; //some code if ((k & mask) != 0) p = &right[*p]; else p = &left[*p]; } In if VS produces the following error
The address of an unfixed expression can be obtained only inside the initializer of the fixed statement
I do not understand how to solve the problem using this operator. Help to understand, please.
PS using the fixed operator, as shown in the example from msdn , did not work, because in that example it is necessary to write an int *p = &variable construct in parentheses, and I already have int *p in the beginning of the code, and in the process it is successfully assigned and changed, but when it comes to if , an error occurs.