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

首頁 > 學(xué)院 > 開發(fā)設(shè)計 > 正文

【轉(zhuǎn)載】#443

2019-11-17 03:18:13
字體:
供稿:網(wǎng)友

【轉(zhuǎn)載】#443 - An Interface Cannot Contain Fields

An interface can contain methods, PRoperties, events or indexers. It cannot contain fields.

1 interface IMoo2 {3     // Methods4     void Moo();5 6     // Field not allow - compile-time error7     string Name;8 }

Instead of a field, you can use a property.

1 interface IMoo2 {3      // Methods4      void Moo();5  6      // Name as a property is OK7      string Name{get; set;}8 }

Interfaces don't allow fields because they consist of a constract that is a list of methods, whose implementation is provided by a class. Properties are implemented as methods (get and set accessors), so they fit this model. But fields are just data locations, so it doesn't make sense to include them in an interface.

原文地址:#443 - An Interface Cannot Contain Fields


發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 萝北县| 阳山县| 丰都县| 古浪县| 香格里拉县| 亚东县| 林芝县| 高阳县| 肃宁县| 乐都县| 台州市| 景泰县| 香格里拉县| 临安市| 南雄市| 思南县| 昭苏县| 栾城县| 调兵山市| 孝昌县| 本溪市| 迁安市| 和田市| 将乐县| 新宁县| 榕江县| 蓬安县| 华容县| 扬中市| 柳河县| 静海县| 孝昌县| 乌拉特后旗| 吴旗县| 崇阳县| 建宁县| 隆林| 信阳市| 石渠县| 噶尔县| 永兴县|