中文亚洲精品无码_熟女乱子伦免费_人人超碰人人爱国产_亚洲熟妇女综合网

當(dāng)前位置: 首頁 > news >正文

我的網(wǎng)站首頁打不開b站2023年免費(fèi)入口

我的網(wǎng)站首頁打不開,b站2023年免費(fèi)入口,國外專賣模板的網(wǎng)站,制標(biāo)易logo設(shè)計(jì)以下示例演示如何定義抽象屬性。 抽象屬性聲明不提供屬性訪問器的實(shí)現(xiàn),它聲明該類支持屬性,而將訪問器實(shí)現(xiàn)留給派生類。 以下示例演示如何實(shí)現(xiàn)從基類繼承抽象屬性。 此示例由三個(gè)文件組成,其中每個(gè)文件都單獨(dú)編譯,產(chǎn)生的程序集由…

以下示例演示如何定義抽象屬性。 抽象屬性聲明不提供屬性訪問器的實(shí)現(xiàn),它聲明該類支持屬性,而將訪問器實(shí)現(xiàn)留給派生類。 以下示例演示如何實(shí)現(xiàn)從基類繼承抽象屬性。

此示例由三個(gè)文件組成,其中每個(gè)文件都單獨(dú)編譯,產(chǎn)生的程序集由下一次編譯引用:

  • abstractshape.cs:包含抽象 Area 屬性的 Shape 類;
  • shapes.cs:Shape 類的子類;
  • shapetest.cs:測試程序,用于顯示一些 Shape 派生對象的區(qū)域;

若要編譯該示例,請使用以下命令:

csc abstractshape.cs shapes.cs shapetest.cs

這將創(chuàng)建可執(zhí)行文件 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

聲明抽象屬性時(shí)(如本示例中的 Area),只需指明哪些屬性訪問器可用即可,不要實(shí)現(xiàn)它們。 在此示例中,僅 get 訪問器可用,因此該屬性是只讀屬性。

下面的代碼演示 Shape 的三個(gè)子類,并演示它們?nèi)绾翁娲?Area 屬性來提供自己的實(shí)現(xiàn)。

// 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;}}
}

下面的代碼演示一個(gè)創(chuàng)建若干 Shape 派生對象并輸出其區(qū)域的測試程序。

// 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.risenshineclean.com/news/27558.html

相關(guān)文章:

  • 住房和城鄉(xiāng)建設(shè)部網(wǎng)站報(bào)名瀏覽器打開
  • 新鄉(xiāng)住房與城鄉(xiāng)建設(shè)廳網(wǎng)站網(wǎng)站推廣營銷
  • 智聯(lián)招聘網(wǎng)站怎么做兩份簡歷360優(yōu)化大師軟件
  • 做啥英文網(wǎng)站賺錢互聯(lián)網(wǎng)公司網(wǎng)站模板
  • 電子商務(wù)網(wǎng)站建設(shè)實(shí)訓(xùn)展示流量網(wǎng)站
  • 臺(tái)州網(wǎng)站建設(shè)方案優(yōu)化廣告設(shè)計(jì)
  • 網(wǎng)站開發(fā)方案書博客站長統(tǒng)計(jì) 站長統(tǒng)計(jì)
  • 微信網(wǎng)站是什么意思昆明網(wǎng)絡(luò)推廣公司排名
  • 如何鑒別建設(shè)銀行網(wǎng)站真?zhèn)位潴w育網(wǎng)體育
  • 杭州推薦網(wǎng)站建設(shè)團(tuán)隊(duì)深圳做推廣哪家比較好
  • 做建筑設(shè)計(jì)網(wǎng)站怎么建立網(wǎng)站平臺(tái)
  • 坊網(wǎng)站建設(shè)seo快速排名工具
  • ps怎么排版規(guī)劃設(shè)計(jì)網(wǎng)站國外網(wǎng)站推廣平臺(tái)有哪些?
  • 在線咨詢網(wǎng)站模板做app推廣去哪找商家
  • 網(wǎng)站建設(shè)模板網(wǎng)站排名優(yōu)化快速
  • 自建個(gè)人網(wǎng)站怎么自己創(chuàng)建一個(gè)網(wǎng)頁
  • wordpress 游戲模版seo輿情優(yōu)化
  • crm管理seo培訓(xùn)一對一
  • 做網(wǎng)站應(yīng)注意什么新網(wǎng)域名注冊查詢
  • 寶安商城網(wǎng)站建設(shè)哪家便宜百度搜索引擎平臺(tái)
  • 興化網(wǎng)站建設(shè)推廣軟文發(fā)布平臺(tái)
  • 做任務(wù)得傭金的網(wǎng)站seo綜合查詢中的具體內(nèi)容有哪些
  • 怎么做免費(fèi)的網(wǎng)站推廣高級seo
  • oa軟件開發(fā)定制seo求職
  • 網(wǎng)站文字設(shè)計(jì)搜索引擎營銷sem包括
  • 一個(gè)公司多個(gè)網(wǎng)站做優(yōu)化今天新聞?lì)^條
  • 網(wǎng)站建設(shè)與維護(hù)作業(yè)東莞seo計(jì)費(fèi)管理
  • 網(wǎng)站建設(shè)推廣怎么做百度旗下產(chǎn)品
  • 建設(shè)網(wǎng)站后怎么發(fā)布長沙網(wǎng)絡(luò)推廣公司
  • 網(wǎng)站打開的速度慢網(wǎng)絡(luò)營銷的工具和方法有哪些