惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Simon Willison's Weblog
Simon Willison's Weblog
G
Google Developers Blog
Spread Privacy
Spread Privacy
I
InfoQ
V
V2EX
S
Schneier on Security
小众软件
小众软件
C
CERT Recently Published Vulnerability Notes
博客园 - 聂微东
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Stack Overflow Blog
Stack Overflow Blog
T
Threat Research - Cisco Blogs
L
Lohrmann on Cybersecurity
Recent Announcements
Recent Announcements
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Attack and Defense Labs
Attack and Defense Labs
云风的 BLOG
云风的 BLOG
The Hacker News
The Hacker News
S
SegmentFault 最新的问题
C
Cybersecurity and Infrastructure Security Agency CISA
NISL@THU
NISL@THU
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
GbyAI
GbyAI
Latest news
Latest news
S
Secure Thoughts
Project Zero
Project Zero
MongoDB | Blog
MongoDB | Blog
I
Intezer
Security Latest
Security Latest
Apple Machine Learning Research
Apple Machine Learning Research
Vercel News
Vercel News
N
Netflix TechBlog - Medium
V2EX - 技术
V2EX - 技术
量子位
T
Threatpost
T
The Blog of Author Tim Ferriss
Y
Y Combinator Blog
T
Tor Project blog
A
Arctic Wolf
Microsoft Security Blog
Microsoft Security Blog
T
The Exploit Database - CXSecurity.com
大猫的无限游戏
大猫的无限游戏
T
Tailwind CSS Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
C
Check Point Blog
博客园 - Franky
Google DeepMind News
Google DeepMind News
The Register - Security
The Register - Security
The GitHub Blog
The GitHub Blog
L
LINUX DO - 热门话题

博客园 - foson

ASP.NET网络编程中常用到的27个函数集 将 ASP 转换为 ASP.NET(转载) MIS和ERP的区别 ViewState 的工作原理 Ajax程序设计入门 AJAX技术浅谈(转载) Asp.net与SQL一起打包部署安装 ASP.NET验证码的实现 关于权限控制(转载) 新的起点----中润基业 ASP.NET中的身份验证方式 两道SQL面试题目 ASP.NET的Application、Session、Cookie、ViewState和Cache等变量的区别是什么? ASP.NET两个页面之间传递值的几种方式 .net 基本概念 DataSet与DataReader的区别 ADO 与ADO.NET两种数据访问方式区别? C# 检查字符串,防SQL注入攻击 c#.net常用函数和方法集
C#中接口与类的区别?
foson · 2006-04-28 · via 博客园 - foson

1、接口类似于类,但接口的成员都没有执行方式,它只是方法、属性、事件和索引符的组合而已,并且也只能包含这四种成员;类除了这四种成员之外还可以别的成员(如字段)。
2、不能实例化一个接口,接口只包括成员的签名;而类可以实例化(abstract类除外)。
3、接口没有构造函数,类有构造函数。
4、接口不能进行运算符的重载,类可以进行运算符重载。
5、接口的成员没有任何修饰符,其成员总是公共的,而类的成员则可以有修饰符(如:虚拟或者静态)。
6、派生于接口的类必须实现接口中所有成员的执行方式,而从类派生则不然。
那么为什么还要有接口呢?主要原因是它是一种有效的契约。类有一些成员,不考虑把这些成员组合在一起,类只是一个拥有各种方法、字段和属性的列表,但为了能以某种方式使用类,必须知道类能执行那些功能,具体的操作就是声明执行一个或多个接口的类,类执行接口的方式是从接口中派生,再提供这个接口中定义的所有成员的执行方式。

posted on 2006-04-28 18:37  foson  阅读(883)  评论(0)    收藏  举报