Using System; Using System. Collections. Generic; Using System. LINQ; Using System. text; Using System. Threading. tasks; Namespace Study { Public Class Program { /// <Summary> /// The ref keyword allows input of a value type to be passed by reference. /// </Summary> Private Static Void Reffunction ( Int X, Ref Int A) { = * X ;} /// <Summary> /// Use of the out keyword /// With the out keyword, you do not need to initialize the input parameter STR before it is passed to the outkeyword () method. If there is no keyword, it cannot be compiled. /// </Summary> Private Static Void Outkeyword ( Out String Str ){ // The output parameter STR must be assigned a value before returning the method. STR =" A string " ;} Static Void Main ( String [] ARGs ){ // * ********** Use of the ref keyword Int X = 12 , A = 5 ; Console. writeline (); // Output: 5 Reffunction (X, Ref A); console. writeline (); // Output: 60 // * ********** Use of the out keyword String STR; // No initialization required Outkeyword ( Out Str ); // Output: a string Console. writeline (STR); console. readkey ();}}}
OriginalArticle, Reprint please indicate the source: http://www.cnblogs.com/hongfei/archive/2013/01/04/2844624.html