C# 关键字Abstract
2021-03-19 14:26
标签:sealed ati int public ogr style rri 一个 tostring C# 关键字Abstract 标签:sealed ati int public ogr style rri 一个 tostring 原文地址:https://www.cnblogs.com/YourDirection/p/12328968.html
1 namespace FirstCode.EX1
2 {
3 abstract public class Shape
4 {
5 abstract public int area();
6 }
7 }
1 namespace FirstCode.EX1
2 {
3 public class Rectangle : Shape
4 {
5 public int width;
6 public int length;
7
8 public Rectangle(int a,int b)
9 {
10 width =a;
11 length = b;
12 }
13 public override int area()=>width*length;
14
15 }
16 }
1 namespace FirstCode
2 {
3 class Program
4 {
5 static void Main(string[] args)
6 {
7 Console.WriteLine("Hello World!");
8
9 Rectangle rect1 = new Rectangle(2,3);
10 Console.WriteLine(rect1.area().ToString());
11 }
12 }
13 }