C # data type value transfer and reference transfer,
/// <Summary> // Computer class // </summary> public class Computer {public string Type {get; set ;}}
/// <Summary> ///// </summary> /// <param name = "computers"> User-input data to be processed </param> // /<returns> processed result data </returns> public Computer [] Func (Computer [] computers) {// apple + little apple // Lenovo ++ little Lenovo // HP little HP // conclusion: the array has two traversal methods, there is a Computer object computer in the foreach/* foreach (computer Computer in computers) {// array. type = "small" + computer. type;} // return computers in 12 minutes ;}
Static void Main (string [] args) {// ToolA toolA = new ToolA (); // toolA. func ("Zhang Ying"); // ToolB B = new ToolB (); // string result = B. func ("cold rain training camp"); // Console. writeLine (result); ToolC c = new ToolC (); Computer [] comps = new Computer [3]; comps [0] = new Computer (); comps [0]. type = "apple"; comps [1] = new Computer (); comps [1]. type = "Lenovo"; comps [2] = new Computer (); comps [2]. type = "HP"; Computer [] compsnew = c. func (comps); foreach (Computer computer in compsnew) {Console. writeLine (computer. type);} Console. readKey ();