当前位置: 首页 > news >正文

网站搭建后台百度竞价排名叫什么

网站搭建后台,百度竞价排名叫什么,门户网站建设及运营,wordpress显示问题以下示例演示如何定义抽象属性。 抽象属性声明不提供属性访问器的实现,它声明该类支持属性,而将访问器实现留给派生类。 以下示例演示如何实现从基类继承抽象属性。 此示例由三个文件组成,其中每个文件都单独编译,产生的程序集由…

以下示例演示如何定义抽象属性。 抽象属性声明不提供属性访问器的实现,它声明该类支持属性,而将访问器实现留给派生类。 以下示例演示如何实现从基类继承抽象属性。

此示例由三个文件组成,其中每个文件都单独编译,产生的程序集由下一次编译引用:

  • abstractshape.cs:包含抽象 Area 属性的 Shape 类;
  • shapes.cs:Shape 类的子类;
  • shapetest.cs:测试程序,用于显示一些 Shape 派生对象的区域;

若要编译该示例,请使用以下命令:

csc abstractshape.cs shapes.cs shapetest.cs

这将创建可执行文件 shapetest.exe。

示例

此文件声明 Shape 类,该类包含 double 类型的 Area 属性。

// compile with: csc -target:library abstractshape.cs
public abstract class Shape
{private string name;public Shape(string s){// calling the set accessor of the Id property.Id = s;}public string Id{get{return name;}set{name = value;}}// Area is a read-only property - only a get accessor is needed:public abstract double Area{get;}public override string ToString(){return $"{Id} Area = {Area:F2}";}
}

属性的修饰符放置在属性声明中。 例如:

public abstract double Area

声明抽象属性时(如本示例中的 Area),只需指明哪些属性访问器可用即可,不要实现它们。 在此示例中,仅 get 访问器可用,因此该属性是只读属性。

下面的代码演示 Shape 的三个子类,并演示它们如何替代 Area 属性来提供自己的实现。

// compile with: csc -target:library -reference:abstractshape.dll shapes.cs
public class Square : Shape
{private int side;public Square(int side, string id): base(id){this.side = side;}public override double Area{get{// Given the side, return the area of a square:return side * side;}}
}public class Circle : Shape
{private int radius;public Circle(int radius, string id): base(id){this.radius = radius;}public override double Area{get{// Given the radius, return the area of a circle:return radius * radius * System.Math.PI;}}
}public class Rectangle : Shape
{private int width;private int height;public Rectangle(int width, int height, string id): base(id){this.width = width;this.height = height;}public override double Area{get{// Given the width and height, return the area of a rectangle:return width * height;}}
}

下面的代码演示一个创建若干 Shape 派生对象并输出其区域的测试程序。

// compile with: csc -reference:abstractshape.dll;shapes.dll shapetest.cs
class TestClass
{static void Main(){Shape[] shapes ={new Square(5, "Square #1"),new Circle(3, "Circle #1"),new Rectangle( 4, 5, "Rectangle #1")};System.Console.WriteLine("Shapes Collection");foreach (Shape s in shapes){System.Console.WriteLine(s);}}
}
/* Output:Shapes CollectionSquare #1 Area = 25.00Circle #1 Area = 28.27Rectangle #1 Area = 20.00
*/
http://www.khdw.cn/news/1696.html

相关文章:

  • c 做特产网站广告推广方案怎么写
  • 网站自己做还是用程序seo运营是什么
  • 多用户商城系统源码教程青岛百度快速排名优化
  • 最新网站建设常见问题品牌seo主要做什么
  • 郑州网站建设优化公司营销网站建站公司
  • 做宣传 为什么要做网站那交换友情链接的意义是什么
  • 如何做家政网站搜索引擎排名优化
  • 毕节网站建设兼职20条优化措施
  • 网站建设需要的技能有哪些上海谷歌seo
  • 有域名有空间怎么做网站上海网站建设服务
  • 代运营工作内容安卓优化大师hd
  • 网站seo快速排名软件友情链接2598
  • 黄石网站设计公司如何在百度搜索排名靠前
  • 济南的网站建设公司网站运营包括哪些内容
  • 电脑wordpress客服端seo企业优化顾问
  • 海南网站建设哪家专业创建网页
  • 阳江网站推广优化seo引擎优化是什
  • 网站制作应用知识东莞谷歌推广
  • 温州定制网站建设电话市场调研报告模板
  • 泉州外贸网站建设都有哪些公司360营销推广
  • 生物科技网站建设方案可以营销的十大产品
  • 送上门卤菜网站要怎么做网站建站教程
  • 产品互联网做推广做什么网站好内蒙古最新消息
  • 国内建站公司淮安网站seo
  • 网站建设工作分解网页是怎么制作的
  • 网站开发专业公司有哪些软文营销策划
  • 静海网站建设广州网站seo推广
  • wordpress万年历插件上海关键词优化报价
  • 备案的网站名称写什么百度做广告推广怎么样
  • 义乌城市投资建设集团网站淄博seo