Is it possible to get or set private fields?
I want to get System.Guid.c
. Is there a way to access it or should I just copy the code from the strut and
While it's possible to do this with reflection, it may be easier to simply retrieve c
from System.Guid.ToByteArray()
.
byte[] guid = guid.ToByteArray();
short c = (short)((guid[7] << 8) | guid[6]);
Since this approach uses public and documented methods, it is less subject to change between versions. (In general, relying on private implementation details should be avoided, since these details can change from version to version.)