I want to get the address of a private field in c#.
Here is my code:
var theString = "Text";
var firstCharRef = theString.GetType().GetField("m_firstChar", BindingFlags.NonPublic | BindingFlags.Instance);
var val = (char)firstCharRef.GetValue(theString);
unsafe
{
char* pointer = &val;//of course, this gives me val address
}
I want to know the address of "m_firstChar".
How to accomplish that?
Aucun commentaire:
Enregistrer un commentaire