日期:2014-05-17 浏览次数:21406 次
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Test t = new Test
{
TestField = { new Student { Name = "ss", Age = 111 } }//TestField是只读的 怎么 还能这么写
};
}
}
public class Student
{
public string Name { get; set; }
public int Age { get; set; }
}
public class Test
{
public StuCollection _testField;
public StuCollection TestField
{
get
{
if (_testField == null)
{
_testField = new StuCollection();
}
return _testField;
}
}
}
public class StuCollection : List<Student>
{
}