C # manually read and write the app config source code,
Public class ConfigOperator {public string strFileName; public string configName; public string configValue; public ConfigOperator () {// TODO: add the constructor logic //} public string ReadConfig1 (string configKey) {configValue = ""; configValue = ConfigurationSettings. appSettings ["+ configKey +" "]; return configValue;} // obtain the config file name of the program and its full path public void SetConfigName (string strConfigName) {configName = strConfigName; // obtain the full path of the configuration file GetFullPath ();} public void GetFullPath () {// obtain the full path of the configuration file strFileName = AppDomain. currentDomain. baseDirectory. toString () + configName;} public void SaveConfig (string configKey, string configValue) {XmlDocument doc = new XmlDocument (); doc. load (strFileName); // find all elements named "add" XmlNodeList nodes = doc. getElementsByTagName ("add"); for (int I = 0; I <nodes. count; I ++) {// obtain the key attribute XmlAttribute att = nodes [I] of the current element. attributes ["key"]; // determines whether the current element is the target element if (att. value = "" + configKey + "") {// assign att = nodes [I] to the second attribute in the target element. attributes ["value"]; att. value = configValue; break ;}// Save the modified doc above. save (strFileName);} public string ReadConfig (string configKey) {string tempStr = ""; XmlDocument doc = new XmlDocument (); doc. load (strFileName); // find all elements named "add" XmlNodeList nodes = doc. getElementsByTagName ("add"); for (int I = 0; I <nodes. count; I ++) {// obtain the key attribute XmlAttribute att = nodes [I] of the current element. attributes ["key"]; // determines whether the current element is the target element if (att. value = "" + configKey + "") {// assign att = nodes [I] to the second attribute in the target element. attributes ["value"]; tempStr = att. value ;}}// Save the above modification return tempStr ;}}
C language ^ how to use
A1 = 0x01; // 0000 0001
A2 = 0x00; // 0000 0000
A3 = 0x03; // 0000 0011
A4 = 0x02; // 0000 0010
B1 = a1 ^ a2; // 0000 0001
B2 = a1 ^ a3; // 0000 0010
B3 = a1 ^ a4; // 0000 0011
^ XOR operator. The bitwise value is 0 and the difference is 1. See the example above.
//
Examples of simple and practical problems:
====================================
======= A ======= B =========
There are two circuits on the top. The two switches are a and B respectively. The opening status is \ [1], and the closing status is/[0].
If both circuits are enabled or disabled.
If a turns on [1], B turns off [0], and circuit 1 Powers on
=====================
If a disables [0], B enables [1], and circuit 2 powers on.
====================================
In summary, the circuit fails in the and B states simultaneously [0]. When a and B are different, the power is charged [1].
C language ^ how to use
A1 = 0x01; // 0000 0001
A2 = 0x00; // 0000 0000
A3 = 0x03; // 0000 0011
A4 = 0x02; // 0000 0010
B1 = a1 ^ a2; // 0000 0001
B2 = a1 ^ a3; // 0000 0010
B3 = a1 ^ a4; // 0000 0011
^ XOR operator. The bitwise value is 0 and the difference is 1. See the example above.
//
Examples of simple and practical problems:
====================================
======= A ======= B =========
There are two circuits on the top. The two switches are a and B respectively. The opening status is \ [1], and the closing status is/[0].
If both circuits are enabled or disabled.
If a turns on [1], B turns off [0], and circuit 1 Powers on
=====================
If a disables [0], B enables [1], and circuit 2 powers on.
====================================
In summary, the circuit fails in the and B states simultaneously [0]. When a and B are different, the power is charged [1].