国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > C# > 正文

c# Base關(guān)鍵字的使用

2020-01-24 03:45:52
字體:
供稿:網(wǎng)友
復(fù)制代碼 代碼如下:

using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class 繼承1
{
//virtual虛函數(shù),這樣寫便于子類重寫
public virtual double Area(double a)
{
return a * 2;
}
}
class Test : 繼承1
{
//重寫父類的Area,當(dāng)然也可以調(diào)用父類的Area方法
public override double Area(double b)
{
//關(guān)鍵字base.Area()調(diào)用了父類的Area方法
return base.Area(b) * 0.9;
}
}
class Result
{
static void Main()
{
Test TT = new Test();
Console.WriteLine(TT.Area(10));
}
}
}

復(fù)制代碼 代碼如下:

using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Class4
{
//申明2個構(gòu)造函數(shù)
public Class4()
{
Console.WriteLine("Class4");
}
int i;
public Class4(int a)
{
i=a;
Console.WriteLine("Class:{0}", i);
}
public void SS()
{
Console.WriteLine("BOSS");
}
}
class Test:Class4
{
//調(diào)用父類(無參數(shù)的)構(gòu)造函數(shù)
public Test()
: base()
{
}
//調(diào)用父類(有參數(shù)的)構(gòu)造函數(shù)
public Test(int a)
: base(a)
{
base.SS();
}
}
class TT
{
static void Main()
{
Test T = new Test();
Test T1 = new Test(10);
}
}
}
發(fā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 海城市| 政和县| 安丘市| 元氏县| 开鲁县| 威信县| 乐安县| 盈江县| 醴陵市| 达孜县| 英德市| 瑞昌市| 阳春市| 德令哈市| 滦平县| 鲁甸县| 博客| 诸城市| 浪卡子县| 文登市| 英德市| 钦州市| 家居| 河源市| 纳雍县| 什邡市| 灵丘县| 丰台区| 东阿县| 思茅市| 浦东新区| 江孜县| 成都市| 东阳市| 牟定县| 贡嘎县| 商都县| 道真| 绥化市| 阳春市| 乳源|