码迷,mamicode.com
首页 > 其他好文 > 详细

test

时间:2019-10-08 14:18:52      阅读:60      评论:0      收藏:0      [点我收藏+]

标签:int   pac   col   names   text   system   read   span   reading   

 1 using System;
 2 using System.Collections.Generic;
 3 using System.Linq;
 4 using System.Text;
 5 using System.Threading.Tasks;
 6 
 7 namespace _26对象数组
 8 {
 9     class Program
10     {
11         static void Main(string[] args)
12         {
13             // -------------------------------- 常规的数组类型--------------------------------
14             string name = "张三";
15             string[] names = new string[] { "张三", "李四", "王五" };
16             int[] ages = new int[] { 12, 15, 23 };
17             // -------------------------------- 对象数组 --------------------------------
18             Student[] students = new Student[30];
19             // --------------------------------学生1
20             Student stu1 = new Student();
21             stu1.StuName = "张三";
22             stu1.ClassName = "一年级";
23             stu1.Age = 14;
24             stu1.StuNum = "S12090414";
25             // --------------------------------学生2
26             Student stu2 = new Student();
27             stu2.StuName = "李四";
28             stu2.ClassName = "二年级";
29             stu2.Age = 20;
30             stu2.StuNum = "22090414";
31             // -------------------------------- 将学生放置于数组之中
32             students[0] = stu1;
33             students[1] = stu2;
34 
35             // -------------------------------- 学生数组的打印
36             for (int i = 0; i < students.Length; i++)
37             {
38                 Console.WriteLine($"{students[i].StuName}的年龄是{students[i].Age},在{students[i].ClassName},学号是{students[i].StuNum}");
39             }
40         }
41     }
42 }

 

test

标签:int   pac   col   names   text   system   read   span   reading   

原文地址:https://www.cnblogs.com/sauhom/p/11634817.html

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