// The ClsPublic class in the dynamic link library has a variable private static string key = "1111 ";
// Modify and obtain the value through the reflection technique below
// Set the key
Public static void updatePalmKey (string key = "test") {BindingFlags flag = BindingFlags. static | BindingFlags. nonPublic; FieldInfo f_key = typeof (ClsPublic ). getField ("key", flag); f_key.SetValue (new ClsPublic (), key );}////// Obtain the key //////
Public static string getPalmKey () {BindingFlags flag = BindingFlags. static | BindingFlags. nonPublic; FieldInfo f_key = typeof (ClsPublic ). getField ("key", flag); object o = f_key.GetValue (new ClsPublic (); return o. toString ();}
// Obtain attributes in the modified class through reflection
class Test
{
public string StrTest {get; set;};
}
////// Get the attributes in the modified class //////
Public void GetAndSetProperty (){
Test t = new Test();
PropertyInfo p=t.GetType().GetProperty("StrTest");
p.SetValue(p,"test"); }
////// Obtain the key //////
Public static string getPalmKey () {BindingFlags flag = BindingFlags. static | BindingFlags. nonPublic; FieldInfo f_key = typeof (ClsPublic ). getField ("key", flag); object o = f_key.GetValue (new ClsPublic (); return o. toString ();}