码迷,mamicode.com
首页 > Windows程序 > 详细

C#初始化器

时间:2017-09-10 14:23:00      阅读:205      评论:0      收藏:0      [点我收藏+]

标签:ram   第一个   ogr   eric   一个   c#   system   console   line   

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

namespace ConsoleApplication8
{
    class Program
    {
        static void Main(string[] args)
        {
            a ee = new a() { a1 = "第一个",a2 = "第二个", a3 = "第三个" };

            a tt = new a("哈哈1") { a2 = "哈哈2", a3 = "哈哈3" };

            Console.WriteLine("{0}{1}{2}",ee.a1,ee.a2,ee.a3);
            Console.WriteLine("{0}{1}{2}", tt.a1, tt.a2, tt.a3);
        }
    }


    class a
    {
        public  string a1{get; set;}
        public string a2 { get; set; }
        public string a3 { get; set; }

        public a(string dd)
        {
            this.a1 = dd;
        }

        public a()
        {
            
        }
    }
}

输出:

第一个第二个第三个
哈哈1哈哈2哈哈3

C#初始化器

标签:ram   第一个   ogr   eric   一个   c#   system   console   line   

原文地址:http://www.cnblogs.com/wangxingzhou/p/7500922.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!