using System;
namespace lesson12_结构体练习题
{
#region 练习题1
//使用结构体描述学员的信息,姓名,性别,年龄,班级,专业,创建两个学员对象,并对其基本信息进行初始化并打印
struct Student
{
string name;
bool sex;
int age;
int cl;
string pr;
public Student(string name, bool sex, int age, int cl, string pr)
{
this.name = name;
this.sex = sex;
this.age = age;
this.cl = cl;
this.pr = pr;
}
public void Speak()
{
Console.WriteLine("姓名:{0},性别:{1},年龄:{2},班级:{3},专业:{4}", name, sex, age, cl, pr);
}
}
#endregion
#region 练习题2
//请简要描述private和public两个关键字的区别
//public 和 private 用来修饰变量和方法的 public 公共的 可以被外部访问 private 私有的 只能在内部使用
#endregion
#region 练习题3
//使用结构体描述矩形的信息,长,宽;创建-个矩形, 对其长宽进行初始化,并打印矩形的长、宽、面积、周长等信息。