- 1
- 0
- 约2.21千字
- 约 9页
- 2016-12-30 发布于江西
- 举报
构造函数的声明与方法调用.doc
struct Student // 声明结构类型
{
// 为结构声明三个字段
public string StudentID;
public string Name;
public byte Age;
public void ShowStudentInfo() // 为结构声明一个方法
{
Console.WriteLine(学号:{0}, this.StudentID);
Console.WriteLine(姓名:{0}, this.Name);
Console.WriteLine(年龄:{0}\n, this.Age);
}
};
class Program
{
static void Main(string[] args)
{
Student student1; // 声明结构变量
// 对结构的字段成员赋值
student1.StudentID = 001;
student1.Name = 李小明;
原创力文档

文档评论(0)