同样的消息被不同类型的对象接收时导致完全不同的行为称为()
查看答案
用new创建一个对象时,将在()为对象分配内存。对象变量存储的是()。
在非密封类中为了防止某个实例成员在子类中被重写,可以将该成员声明为成员。
阅读程序,写出程序运行结果:class Program{static void Main(string[] args){Shape[] s = {new Rectangle("矩形",2.0,3.0),new Circle("圆",3.5)};foreach(Shape shape in s){shape.Show();}Console.ReadKey();}}public abstract class Shape{protected string name;public Shape(string name){this.name = name;}public abstract void Show();public abstract double Area();}public class Rectangle : Shape{protected double weight;protected double height;public Rectangle(string name,double w,double h) : base(name){this.weight = w;this.height = h;}public override void Show(){Console.WriteLine("Rectangle:{0},area:{1:N2}",name,weight * height);}public override double Area(){return weight * height;}}public class Circle : Shape{protected double radius;public Circle(string name,double r) : base(name){this.radius = r;}public override void Show(){Console.WriteLine("Circle:{0},area:{1:N2}",name,Math.PI * radius * radius);}public override double Area(){return Math.PI * radius * radius;}}