/*
--===------------------------------------------===---
Object Initializer: 对象初始化器
可以直接对属性赋值
--===------------------------------------------===--- */
using System;
namespace xumh
{
public class student
{
public string Name{ get ; set ;}
public int Age{ get ; set ;}
public string Address{ get ; set ;}
}
public class runMyApp
{
static void Main()
{
// 对象初始化器,在{}内直接对属性赋值,采用,分割
student stu = new student{Name = " 许明会 " , Age = 35 , Address = " 北大青鸟 " };
System.Console.WriteLine( " {0},年龄{1},地址{2}. " ,
stu.Name,stu.Age,stu.Address);
}
}
}
Object Initializer: 对象初始化器
可以直接对属性赋值
--===------------------------------------------===--- */
using System;
namespace xumh
{
public class student
{
public string Name{ get ; set ;}
public int Age{ get ; set ;}
public string Address{ get ; set ;}
}
public class runMyApp
{
static void Main()
{
// 对象初始化器,在{}内直接对属性赋值,采用,分割
student stu = new student{Name = " 许明会 " , Age = 35 , Address = " 北大青鸟 " };
System.Console.WriteLine( " {0},年龄{1},地址{2}. " ,
stu.Name,stu.Age,stu.Address);
}
}
}