public struct Student
{
public int age;
public string sex;
public string name;
public int id;
public Student (int age, string sex, string name, int id)
{
this.age = age;
this.sex = sex;
this.name = name;
this.id = id;
}
public void Introduce ()
{
Console.WriteLine ("My name is {0},I'm {1} years old.", name, age);
}
}
class Program
{
static void Main (string[] args)
{
Student s1 = new Student ();
s1.name = "Tom";
s1.age = 20;
s1.Introduce ();
Student s2 = new Student (21, "女", "Rose", 1);
s2.Introduce ();
}
}
c#学习笔记 结构体
最新推荐文章于 2023-07-02 16:00:20 发布