C # data type value transfer and reference transfer,

Source: Internet
Author: User

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 ();

  

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.