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

推荐订阅源

H
Help Net Security
C
Cybersecurity and Infrastructure Security Agency CISA
S
Secure Thoughts
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Hacker News: Ask HN
Hacker News: Ask HN
Attack and Defense Labs
Attack and Defense Labs
N
News and Events Feed by Topic
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
A
Arctic Wolf
www.infosecurity-magazine.com
www.infosecurity-magazine.com
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
The GitHub Blog
The GitHub Blog
W
WeLiveSecurity
Simon Willison's Weblog
Simon Willison's Weblog
WordPress大学
WordPress大学
Y
Y Combinator Blog
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Forbes - Security
Forbes - Security
NISL@THU
NISL@THU
博客园 - 聂微东
G
Google Developers Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Schneier on Security
Schneier on Security
V
Vulnerabilities – Threatpost
V
V2EX
I
Intezer
S
Schneier on Security
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
雷峰网
雷峰网
L
LangChain Blog
小众软件
小众软件
Hugging Face - Blog
Hugging Face - Blog
T
The Blog of Author Tim Ferriss
L
LINUX DO - 热门话题
P
Proofpoint News Feed
Microsoft Security Blog
Microsoft Security Blog
Project Zero
Project Zero
V
Visual Studio Blog
Engineering at Meta
Engineering at Meta
爱范儿
爱范儿
H
Hacker News: Front Page
B
Blog
T
Threatpost
Spread Privacy
Spread Privacy
H
Heimdal Security Blog
F
Fortinet All Blogs
TaoSecurity Blog
TaoSecurity Blog
T
Threat Research - Cisco Blogs
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
The Cloudflare Blog

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