using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace 对象初始化器
{
/// <summary>
/// 对象初始化器(语法糖):
/// </summary>
class Program
{
static void Main(string[] args)
{
student student = new student();
student.ld = 1;
student.Name = "小强";
student.Age = 2;
student student2 = new student()
{
ld = 4,
Age = 6,
Name="小李"
};
Console.WriteLine(student.Name);
Console.WriteLine(student2.Name);
Console.ReadLine();
}
}
public class student
{
public int ld{ get; set; }
public string Name { get; set; }
public int Age { get; set; }
}
}