So I am Reflector-ing some framework 2.0 code and end up with the following deconstruction
fixed (void* voidRef3 = ((void*) &_someMember))
{
...
}
This won't compile due to 'The right hand side of a fixed statement assignment may not be a cast expression
'
I understand that Reflector can only approximate and generally I can see a clear path but this is a bit outside my experience.
Question: what is Reflector trying to describe to me?
Update:
Am also seeing the following
fixed (IntPtr* ptrRef3 = ((IntPtr*) &this._someMember))
Update:
So, as Mitch says, it is not a bitwise operator, but an addressOf operator.
Question is now:
fixed (IntPtr* ptrRef3 = &_someMember)
fails with an 'Cannot implicitly convert type 'xxx*' to 'System.IntPtr*'. An explicit conversion exists (are you missing a cast?)
' compilation error.
So I seemed to be damned if I do and damned if I dont. Any ideas?
UPDATE:
I think i have it figured. By chance I went back to the expression that was using void*
and removed the casts and VS stopped complaining and since I gathered from the participants in this conversation that void*
and intptr*
are equivalent I simply swapped them out, resulting in this:
fixed (void* ptrRef3 = &_someMember)
and VS stopped complaining. Can someone verify that
fixed (void* ptrRef3 = &_someMember)
is equivalent to
fixed (IntPtr* ptrRef3 = &_someMember)
?