c# - Variable scope try, finally -
this code. have try , statement. within try block have fixed statement sets pointer variable.
try { fixed (char* chref = p) { //code } } { chref = null; }
im struggling way set fixed pointer variable null no matter how try exits beause of scope. please help.
char* chref; try { fixed (chref = p) { //code } } { chref = null; }
gives me "error 12 type of local declared in fixed statement must pointer type"
were possible, you'd need ensure chref
in scope. , mean putting inside fixed
statement. you'd write this:
fixed (char* chref = p) { try { //code } { chref = null; } }
but not work because not allowed assign pointer chref
. is, after all, fixed! if attempt assign fixed pointer compiler objects:
error cs1656: cannot assign 'chref' because 'fixed variable'
even if this, cannot, there no point. since chref
leave scope, make no sense modify when know nothing ever observe modification.
Comments
Post a Comment