📜  C# 结构 - C# 代码示例

📅  最后修改于: 2022-03-11 14:48:49.160000             🧑  作者: Mango

代码示例1
struct student
{
    public int s_id;
    public String s_name, c_name, dob;
}
class Program
{
    static void Main(string[] args)
    {
        student[] arr = new student[4];

        for(int i = 0; i < 4; i++)
        {
            Console.WriteLine("Please enter StudentId, StudentName, CourseName, Date-Of-Birth");


            arr[i].s_id = Int32.Parse(Console.ReadLine());
            arr[i].s_name = Console.ReadLine();
            arr[i].c_name = Console.ReadLine();
            arr[i].s_dob = Console.ReadLine();
       }
    }
}

 student thisStudent;
 Console.WriteLine("Please enter StudentId, StudentName, CourseName, Date-Of-Birth");
 thisStudent.s_id = int.Parse(Console.ReadLine());
 thisStudent.s_name = Console.ReadLine();
 thisStudent.c_name = Console.ReadLine();
 thisStudent.s_dob = Console.ReadLine();