韩言福地

只有想不到的,没有办不到的。 - HY Auspicious Place

« 人生中不可错过的五句话模型-视图-控制器(MVC)框架 »

构造函数重载时的一些写法


构造函数重载时的一些写法:
public Message() : this(0, null, null)
        {
        }

        public Message(int id): this(id, null, null)
        {
        }

        public Message(int id, string guest, string content)
        {
            this.id = id;
            this.guest = guest;
            this.content = content;
            dateTime = DateTime.Now;
        }


这样方法
: this(0, null, null)直接调用了有3个参数的那个函数

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

日历

最新评论及回复

最近发表

Copyright 2007-2010 www.yinrg.com(HY Auspicious Place) . 湘ICP备06007796号.