构造函数的执行顺序

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BCode_Framework_ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            Customer customer = new Customer("aa", "bb");
            Console.WriteLine(customer.aa);
            Console.WriteLine(customer.bb);
            Console.WriteLine(customer.ee);
            Console.ReadLine();

        }
    }
    public class Customer
    {
        public string aa = "aa未初始化";
        public string bb = "bb未初始化";
        public string ee = "ee未初始化";
        public int i = 0;

        public Customer()
        {
            this.aa = i.ToString();
            i++;
        }
        public Customer(string aa):this()
        {
            this.bb = i.ToString();
            i++;
        }
        public Customer(string aa,string bb):this(bb)
        {
            this.ee = i.ToString();
            i++;
        }

    }
}

 

posted @ 2019-07-31 16:04  马永猛  阅读(284)  评论(0编辑  收藏  举报