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

 interface IMoo
{
// Methods
void Moo(); // Field not allow - compile-time error
string Name;
}

Instead of a field, you can use a property.

 interface IMoo
{
// Methods
void Moo(); // Name as a property is OK
string Name{get; set;}
}

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

【转载】#443 - An Interface Cannot Contain Fields的更多相关文章

  1. 关于C#你应该知道的2000件事

    原文 关于C#你应该知道的2000件事 下面列出了迄今为止你应该了解的关于C#博客的2000件事的所有帖子. 帖子总数= 1,219 大会 #11 -检查IL使用程序Ildasm.exe d #179 ...

  2. window netsh interface portproxy 配置转发

    系统版本 windows server2016 datacenter 1.配置443.80端口转发到其他服务器的443.80上 netsh interface portproxy add v4tov4 ...

  3. [Chromium文档转载,第002章]Mojo C++ Bindings API

    Mojo C++ Bindings API This document is a subset of the Mojo documentation. Contents Overview Getting ...

  4. 从OOP的角度看Golang

    资料来源 https://github.com/luciotato/golang-notes/blob/master/OOP.md?hmsr=toutiao.io&utm_medium=tou ...

  5. DBus学习笔记

    摘要:DBus作为一个轻量级的IPC被越来越多的平台接受,在MeeGo中DBus也是主要的进程间通信方式,这个笔记将从基本概念开始记录笔者学习DBus的过程 [1] DBus学习笔记一:DBus学习的 ...

  6. delphi 保存网页MHT

    delphi 保存网页MHT   uses ADODB_TLB, CDO_TLB, ComObj,MSHTML;{$R *.dfm}{能把网页如 WWW.QQ.COM保存为一个单文件 .MHT但不能把 ...

  7. Global Financial Applications uses the following Public tables

    来自文档: Oracle  Financial Applications Technical Reference Manual  更多明细参考文档 Table Name                 ...

  8. DBUS基础知识

    转:http://www.cnblogs.com/wzh206/archive/2010/05/13/1734901.html DBUS基础知识 1.  进程间使用D-Bus通信 D-Bus是一种高级 ...

  9. C-Language Functions

    转自:https://www.postgresql.org/docs/9.6/xfunc-c.html 可以作为学习基于c编写pg extension 的资料 36.9. C-Language Fun ...

随机推荐

  1. 正确优雅地解决用户退出——JSP及Struts解决方案

    摘要       在一个有密码保护的Web应用中,正确处理用户退出过程并不仅仅只需调用HttpSession的invalidate()方法.现在大部分浏览器上都有后退和前进按钮,允许用户后退或前进到一 ...

  2. nodejs的一些学习

    要使用npm的时候,其实是可以直接下载node.js的.参考文档http://www.runoob.com/nodejs/nodejs-npm.html 安装成功之后.判断是否安装成功.是不能直接用n ...

  3. CentOS 6.2出现Disk sda contains BIOS RAID metadata解决方法

    今天在安装CentOS 6.2的时候,当进到检测硬盘的时候,总是过不去,报错如下: Disk sda contains BIOS RAID metadata, but is not part of a ...

  4. C++指针传递和引用传递的区别 (转载整理)

    区别1:指针传递和引用传递是以不同的方式实现相同的效果,但是指针传递的本质还是值传递,只是传递的值是地址. 就拿 交换两个数的函数来举例: // 指针传递 void swap(int * val1, ...

  5. 3.CAS原子操作

    什么是原子性操作,按照官方的解析:原子操作不能在一个中间操作中停止,要么全部成功要么全部失败.(An atomic action cannot stop in the middle: it eithe ...

  6. windows删除指定日期前的文件

    @ echo offforfiles /p .\ /s /m 2008*.* /d -7 /c "cmd /c echo @file>>.\del.txt"forfil ...

  7. django设置打印数据库日志

    在settings.py中添加: LOGGING = { 'disable_existing_loggers': False, 'version': 1, 'handlers': { 'console ...

  8. unity项目架构

    Unity 游戏框架搭建 (一) 概述Unity 游戏框架搭建 (二) 单例的模板Unity 游戏框架搭建 (三) MonoBehaviour单例的模板Unity 游戏框架搭建 (四) 简易有限状态机 ...

  9. mvp需要加上单利模式

    最大的中介者,需要设置成单利模式

  10. 关于MySQLServer5.6配置问题

    配置MySQL MySQL数据库下载以后在根目录添加my.ini配置文件 需要注意的是配置文件的二个属性: basedir=D:\MySqlServer # mysql所在目录 根据需求改 MySQL ...