首页 > 其他 > 详细

构造函数的执行顺序

时间:2019-07-31 16:40:44      阅读:88      评论:0      收藏:0      [点我收藏+]
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++;
        }

    }
}

技术分享图片

 

构造函数的执行顺序

原文:https://www.cnblogs.com/heibai-ma/p/11276972.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!