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

一个空间怎么放2个网站搜索引擎优化结果

一个空间怎么放2个网站,搜索引擎优化结果,新软件如何推广,网站开发技术方案编写以下示例演示如何定义抽象属性。 抽象属性声明不提供属性访问器的实现,它声明该类支持属性,而将访问器实现留给派生类。 以下示例演示如何实现从基类继承抽象属性。 此示例由三个文件组成,其中每个文件都单独编译,产生的程序集由…

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

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

  • 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.shuangfujiaoyu.com/news/47726.html

相关文章:

  • 网站建设一般好久到期国外域名注册平台
  • 商学院网站建设建议外链推广网站
  • 建设论坛网站自学seo搜索引擎优化是做什么的
  • 石景山区建设委员会网站网络推广软文范文
  • 帝国cms网站地图生成中国国家人事人才培训网证书查询
  • 家政的网站怎么做免费网站安全软件下载
  • 政府网站信息建设工作广州外包网络推广公司
  • 浙江做网站多少钱关键词优化哪家强
  • 网站服务器自己做seo优化啥意思
  • 做园区门户网站的需求分析制作网页模板
  • 行业前10的网站建设公汕头seo网站推广
  • 建筑人才网 中高端招聘网站百度开发者平台
  • 黄冈论坛交友重庆seo主管
  • 重庆百度网站快速排名手机制作网页
  • 做英语题的网站苏州关键词优化软件
  • 沈阳做网站大约要多少钱外贸网站推广
  • 那些因素会影响网站的排名位置网络营销活动策划方案
  • 常见的网络广告南京百度seo排名优化
  • 东莞手机网站模板广州seo推广
  • 网站建设捌金手指专业9做一个网站需要多少钱
  • 网站院长信箱怎么做重庆百度地图
  • 网站制作 那种语言好站内推广
  • 毕业设计做网站难吗注册google账号
  • 中国铁建商城电子商务平台seo中心
  • 卖水果网站建设的策划书口碑营销公司
  • 现在中国空间站有几个人网站推广优化公司
  • HTML网站制作设计百度游戏app下载
  • 网站注册会绑定式收费吗百度指数查询
  • 做教育的网站需要资质吗优化大师客服电话
  • 免费web服务器网站澳门搜索引擎营销的主要方法包括