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

首頁 > 學院 > 開發設計 > 正文

【轉載】#330

2019-11-17 03:18:35
字體:
來源:轉載
供稿:網友

【轉載】#330 - Derived Classes Do Not Inherit Constructors

A derived class inherits all of the members of a base class except for its constructors.

You must define a constructor in a derived classunlessthe base class has defined a default (parameterless) constructor. If you don’t define a constructor in the derived class, the default constructor in the base class is called implicitly.

When you define a constructor in a derived class, you can call a constructor in the base class by using thebasekeyWord.

Here’s an example:

 1 public class Dog 2 { 3     public string Name { get; set; } 4     public int Age { get; set; } 5  6     public Dog(string name, int age) 7     { 8         Name = name; 9         Age = age;10     }11 }12 13 public class Terrier : Dog14 {15     public string Attitude { get; set; }16 17     // Call the Name/Age constructor in the base class18     public Terrier(string name, int age, string attitude)19         : base(name, age)20     {21         Attitude = attitude;22     }23 }

原文地址:#330 - Derived Classes Do Not Inherit Constructors


上一篇:C# 解析 Json數據

下一篇:【轉載】#324

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 大厂| 军事| 庄河市| 阳西县| 苍南县| 太和县| 洞口县| 富川| 黎城县| 平和县| 泉州市| 宁德市| 尚志市| 土默特左旗| 奉贤区| 栾川县| 齐齐哈尔市| 喜德县| 淮阳县| 聊城市| 大城县| 甘孜县| 克东县| 微山县| 沙田区| 栾川县| 修武县| 庆云县| 博爱县| 化州市| 江油市| 若羌县| 斗六市| 定襄县| 山西省| 湘阴县| 白水县| 珲春市| 星座| 长沙市| 马龙县|