类、对象和引用的定义(C# 初学者教程)
类声明:
访问修饰字 class 类名 {
变量声明;
方法声明;
}
例如:
class Student {
long id; // 学号
char gender; // 性别
int classID; // 班级号
void ChangeClass(int aClassID) // 更改班级
{...}
}
对象引用声明:
类名 引用名;
例如:
Student student;
对象创建:
引用名 = new 类构造函数;
例如:
student = new Student();
对象使用:
引用名.变量名 / 方法名(参数)
例如:
student.id = 200328013203194;
4.81MB
文件大小:
评论区