當前位置

首頁 > 商務英語 > 計算機英語 > c中base的用法

c中base的用法

推薦人: 來源: 閱讀: 2.89W 次

c中base的用法的用法你知道嗎?下面小編就跟你們詳細介紹下c中base的用法的用法,希望對你們有用。

padding-bottom: 66.56%;">c中base的用法

c中base的用法的用法如下:

1、調用基類中的重名方法

[csharp]

public class Person

{

protected string ssn = "444-55-6666";

protected string name = "John L. Malgraine";

public virtual void GetInfo()

{

eLine("Name: {0}", name);

eLine("SSN: {0}", ssn);

}

}

class Employee : Person

{

public string id = "ABC567EFG";

public override void GetInfo()

{

// Calling the base class GetInfo method:

nfo();

eLine("Employee ID: {0}", id);

}

}

class TestClass

{

static void Main()

{

Employee E = new Employee();

nfo();

}

}

/*

Output

Name: John L. Malgraine

SSN: 444-55-6666

Employee ID: ABC567EFG

*/

2、調用基類的構造方法

[csharp]

ublic class ActionCancelEventArgs : elEventArgs

{

public ActionCancelEventArgs() : this(false) {}

public ActionCancelEventArgs(bool cancel) : this(false, y) {}

public ActionCancelEventArgs(bool cancel, string message) : base(cancel)

{

age = message;

}

public string Message{ get; set;}

}