国产探花免费观看_亚洲丰满少妇自慰呻吟_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ā)表
主站蜘蛛池模板: 剑川县| 阜康市| 葫芦岛市| 上思县| 乌拉特中旗| 资兴市| 汾西县| 沂水县| 托里县| 阿拉善左旗| 舞钢市| 彩票| 彰化市| 姜堰市| 军事| 平江县| 远安县| 杭锦后旗| 禹城市| 新和县| 怀远县| 郁南县| 福泉市| 永兴县| 乌苏市| 苏尼特左旗| 石狮市| 洪洞县| 泗洪县| 双鸭山市| 祥云县| 潼南县| 武宣县| 宁南县| 贵定县| 垦利县| 长阳| 南雄市| 巴马| 河北省| 锡林浩特市|