C # Basic article/Face test

Source: Internet
Author: User

First, value type and reference type

public static void Main (string[] args)        {            int = 10;//value type an area in memory that holds            an object age1 = age;//The reference type has an address at this point to age The initial address of the            age + = 1;//age re-opens the new area at this time for one,            Console.WriteLine ("fist=" +age1);//point to the old area value is ten;            int age2= (int) age1;/ /reference type conversion value type is ten;            Console.WriteLine ("test=" +age2);            Age2 + = 1;            Console.WriteLine ("Secend=" +age);            Console.readkey ();        }

Output Results 10 10 11

Second, the successor rewrite

public class program    {public        static void Main (string[] args)        {            Employee Yee = new Employee ();            Console.readkey ();        }    }    Class person    {        protected int: age = ten;        Public person ()        {this            . Output ();        }        public virtual void Output ()        {            Console.WriteLine (' Person ' +this.age);        }    }    Class Employee:person    {public        Employee (): Base ()        {            base.age =;        }        public override void Output ()        {            Console.WriteLine ("Employee" +base.age);        }    }

Output Results 10

C # Basic article/Face test

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.