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

推荐订阅源

aimingoo的专栏
aimingoo的专栏
The Last Watchdog
The Last Watchdog
Project Zero
Project Zero
T
Threatpost
T
The Blog of Author Tim Ferriss
云风的 BLOG
云风的 BLOG
N
Netflix TechBlog - Medium
B
Blog
The GitHub Blog
The GitHub Blog
F
Full Disclosure
MyScale Blog
MyScale Blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Y
Y Combinator Blog
GbyAI
GbyAI
Recent Announcements
Recent Announcements
MongoDB | Blog
MongoDB | Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
D
Docker
NISL@THU
NISL@THU
爱范儿
爱范儿
Spread Privacy
Spread Privacy
F
Fortinet All Blogs
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
博客园 - 叶小钗
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Hacker News - Newest:
Hacker News - Newest: "LLM"
Simon Willison's Weblog
Simon Willison's Weblog
S
Security @ Cisco Blogs
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
PCI Perspectives
PCI Perspectives
V
V2EX
人人都是产品经理
人人都是产品经理
W
WeLiveSecurity
IT之家
IT之家
P
Proofpoint News Feed
Engineering at Meta
Engineering at Meta
博客园_首页
Forbes - Security
Forbes - Security
Cloudbric
Cloudbric
有赞技术团队
有赞技术团队
Application and Cybersecurity Blog
Application and Cybersecurity Blog
B
Blog RSS Feed
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
P
Palo Alto Networks Blog
The Register - Security
The Register - Security
Google DeepMind News
Google DeepMind News
Hacker News: Ask HN
Hacker News: Ask HN
腾讯CDC
T
Threat Research - Cisco Blogs
Cyberwarzone
Cyberwarzone

博客园 - 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)    收藏  举报