学校排行榜

(0)

投一票

C#类 官网

类是一种用户自定义的数据类型,定义了对象的属性和方法。 // 定义类class Rectangle { public int width; // 宽度属性 public int height; // 高度属性 public int Area() { return width * height; // 计算面积 }}// 使用类Rectangle rect = new Rectangle();rect.width = 5;rect.height = 3;int area = rect.Area(); // 运行结果:面积为15 类中的属性和方法可设置访问修饰符,控制访问权限。
专业
评论
新闻
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。