答案 0 :(得分:1)
首先,这个挂锁意味着该字段是私有/内部非readonly,您无法直接访问它。
您可以使用Reflection
:
string nameOfTheVariableYouWantToAccess = "_encoding";
Type objType = objectYouWantToGetValueFrom.GetType();
FieldInfo fieldInfo = objType.GetField(nameOfTheVariableYouWantToAccess, BindingFlags.NonPublic | BindingFlags.Instance);
object valueOfTheVariable = fieldInfo.GetValue(objectYouWantToGetValueFrom);