From this field, the ref indicates the reference. out is the output.
Public void getrefstr (Ref String Str) {STR = "Hello, you have changed to ref "}
Public void getoutstr (Out String outstr) {outstr = "Hello, you are the output value of out ";}
Protected void button#click (Object sender, eventargs e) {string Ss = "hello"; getstr (ref SS); response. write (SS); // output ref reference value} protected void button2_click (Object sender, eventargs e) {string outvalue; Method (Out outvalue); response. write (outvalue); // output out value}
The previous image below
Click ref.
Click out
See the instance andCodeNow let's talk about ref and outstring Ss = "hello"; // SS is actually a reference SS ---------> "hello" getstr (ref SS );//Ref SS indicates the getstr (ref string Str) STR method. Buddy, your reference address is ss.Public void getrefstr (ref string Str) {STR = "Hello, you have changed to ref" // reference the main method in the new} ref button {Ss = "hello "; getstr (ref SS); response. write (SS); // so when the value of the input SS changes, because its reference address has changed}
Public void getoutstr (out string outstr) {outstr = "Hello, you are the output value";} out button {string outvalue ;//No null value. Reference outvalue ---------> emptyMethod (Out outvalue); // input reference others' outstr = "Hello, you are the output value of out"; response. write (outvalue); // The output out value changes accordingly}
In the final conclusion, both out and ref are actually the actual reference address, so its value also changes. The previous simple address reference diagram
Each reference opens up memory space.