usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;namespaceconsoleapplication2{classProgram {Static voidMain (string[] args) { stringOutstring ="This is the outstring value"; Console.WriteLine (outstring); BOOLOK = Outmethod ( outoutstring); Console.WriteLine (outstring); Console.WriteLine (OK.) ToString ()); /*I'm the dividing line .*/ stringRefstring ="This is the refstring value"; Console.WriteLine (refstring); BOOLOkk = Refmethod (refrefstring); Console.WriteLine (refstring); Console.WriteLine (Okk. ToString ()); Console.readkey (); } Static BOOLOutmethod ( out stringstr) {STR="This is the new outstring value";//value must be set return true; } Static BOOLRefmethod (ref stringstr) {STR="This is the new outstring value";//This sentence can not be written, that is, do not reset the value return true; } }}
C # base-out and Ref fields