Using System; Namespace prg1 { Class Paramstest { // Value parameter usage demonstration Public static void Transposition_1 (int a, int B) { Int temp =; A = B; B = temp; } // Demo of referencing Parameters Static void Transposition_2 (ref int a, ref int B) { Int temp =; A = B; B = temp; } // Use of output parameters Static void Transposition_3 (string name, out string FistName, out string LastName) { Int I = name. Length; // Get the length of the string While (I> 0) { Char chparm = name [I-1]; If (chparm = '.') { Break; } I --; } FistName = name. Substring (0, I-1 ); LastName = name. Substring (I ); } Static void Main (string [] args) { Int a = 25; Int B = 30; // Call Transposition_1 Console. WriteLine ("Call Transposition_1 before a = {0}, B = {1}", a, B ); Transposition_1 (a, B ); Console. WriteLine ("Call Transposition_1 after a = {0}, B = {1}", a, B ); Console. WriteLine ("===============================\ n "); // Call Transposition_2 Console. WriteLine ("Call Transposition_2 before a = {0}, B = {1}", a, B ); Transposition_2 (ref a, ref B ); Console. WriteLine ("after calling Transposition_2 a = {0}, B = {1}", a, B ); Console. WriteLine ("===============================\ n "); // Call Transposition_3 String DoName, Nmark; Transposition_3 ("rohelm. X", out DoName, out Nmark ); Console. WriteLine ("Domain Name of Myself: {0}", DoName ); Console. WriteLine ("The last name of my Domain Name: {0}" + "\ n", Nmark ); // Call Show String [] NameArray = {"rohelm. X", "Boolean", "rrats "}; Prmarry. Show (NameArray ); Console. ReadKey (); } } Class Prmarry { Public static void Show (params string [] name) { Console. WriteLine ("Array contains the number of elements: {0}", name. Length ); Console. Write ("elements of NameArray :"); For (int I = 0; I <name. Length; I ++) { Console. Write ("{0, 10}", name [I]); } } } } |