博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
初始化构造函数中定义的实体集合,方便嵌套类型的遍历
阅读量:4347 次
发布时间:2019-06-07

本文共 1967 字,大约阅读时间需要 6 分钟。

class Programs    {        public static void OP()        {            Student[] stuinfo = new Student[]             {                  new Student("HB001","Tom",'男',20,new List
(new Archement[]{
new Archement("HB001","大学数学",88),new Archement("HB001","大学语文",88)})), new Student("HB002","Lucy",'女',23,new List
(new Archement[]{
new Archement("HB002","大学数学",88),new Archement("HB002","大学语文",88)})), new Student("HB003","Peter",'男',27,new List
(new Archement[]{
new Archement("HB003","大学数学",88),new Archement("HB003","大学语文",88)})), new Student("HB004","Bruce",'男',30,new List
(new Archement[]{
new Archement("HB004","大学数学",88),new Archement("HB004","大学语文",88)})) }; foreach (var item in stuinfo) { Console.WriteLine("{0}\t{1}\t{2}\t{3}", item.StuID, item.StuName, item.StuSex, item.Age); foreach (var s in item.Score) { Console.WriteLine("{0}\t{1}", s.CourseName, s.Score); } } } } public class Student { public string StuID { get; set; } public string StuName { get; set; } public char StuSex { get; set; } public uint Age { get; set; } public List
Score { get; set; } public Student(string ID, string Name, char Sex, uint Uage, List
lst) { this.StuID = ID; this.StuName = Name; this.StuSex = Sex; this.Age = Uage; Score = new List
(); foreach (var item in lst) { this.Score.Add(item); } } } public class Archement { public string StuNo { get; set; } public string CourseName { get; set; } public double Score { get; set; } public Archement(string ID, string Name, double DScore) { this.StuNo = ID; this.CourseName = Name; this.Score = DScore; } }

 

转载于:https://www.cnblogs.com/shy1766IT/p/6220669.html

你可能感兴趣的文章
Linux的用户态和内核态
查看>>
JavaScript原生错误及检测
查看>>
大众点评实时监控系统CAT的那些坑
查看>>
(原创) cocos2d-x 3.0+ lua 学习和工作(4) : 公共函数(3): 深度克隆clone()
查看>>
为什么写作
查看>>
整数子数组求最大和添加验证
查看>>
【转】通过blob获取图像并显示
查看>>
使用kubeadm安装Kubernetes
查看>>
Principal Component Analysis 主元分析
查看>>
JDBC原生态代码
查看>>
韩版可爱小碎花创意家居收纳挂袋
查看>>
计算机基础之硬件
查看>>
python操作mysql ------- SqlAchemy正传
查看>>
如何使用 JSP JSTL 显示/制作树(tree) 菜单
查看>>
12.5号
查看>>
lintcode-medium-Binary Tree Zigzag Level Order Traversal
查看>>
04-spring框架—— Spring 集成 MyBatis
查看>>
eniac世界第二台计算机
查看>>
logrotate日志切割
查看>>
POJ-3253 Fence Repair 贪心
查看>>