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

推荐订阅源

aimingoo的专栏
aimingoo的专栏
V
V2EX
G
Google Developers Blog
F
Full Disclosure
Martin Fowler
Martin Fowler
宝玉的分享
宝玉的分享
H
Hacker News: Front Page
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
NISL@THU
NISL@THU
G
GRAHAM CLULEY
V
Vulnerabilities – Threatpost
Hacker News - Newest:
Hacker News - Newest: "LLM"
A
About on SuperTechFans
The Cloudflare Blog
C
Cisco Blogs
D
DataBreaches.Net
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Vercel News
Vercel News
P
Privacy International News Feed
Microsoft Security Blog
Microsoft Security Blog
Help Net Security
Help Net Security
Recorded Future
Recorded Future
PCI Perspectives
PCI Perspectives
S
Schneier on Security
AI
AI
N
News | PayPal Newsroom
雷峰网
雷峰网
C
Cyber Attacks, Cyber Crime and Cyber Security
P
Proofpoint News Feed
The Last Watchdog
The Last Watchdog
L
LINUX DO - 最新话题
Hugging Face - Blog
Hugging Face - Blog
Apple Machine Learning Research
Apple Machine Learning Research
Schneier on Security
Schneier on Security
S
Securelist
云风的 BLOG
云风的 BLOG
Stack Overflow Blog
Stack Overflow Blog
博客园_首页
AWS News Blog
AWS News Blog
TaoSecurity Blog
TaoSecurity Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Recent Commits to openclaw:main
Recent Commits to openclaw:main
博客园 - 三生石上(FineUI控件)
C
CXSECURITY Database RSS Feed - CXSecurity.com
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Cloudbric
Cloudbric
C
Cybersecurity and Infrastructure Security Agency CISA
Project Zero
Project Zero
C
Check Point Blog
S
Security Affairs

博客园 - chinachen

查看DLL 版本 平台 x86 x64 MS SQL2008 数据库备份(收集) android 使用sqlite几种方式。 C# 接口 索引 属性 实质及应用 (收集) get set 用法总结 (收集) MVC 资料收集(一) windows运行命令大全 Html:meta标签的奥妙 (收集) - chinachen - 博客园 ASP.NET抓取页面并分析页面数据的研究与探讨。 C#中indexof和substring函数用法 (收集) - chinachen - 博客园 BlogEngine 深入研究(一) 开篇 ASP.NET实现回调服务器方法 (收集) 统一过程,敏捷过程,微软过程(收集) HTTP服务器状态代码定义(Status Code Definitions)(收集) Lambda 表达式 源自MSDN 多个表 导出EXCEL 代码 (分享) C# 参考之方法参数关键字:params、ref及out (收集) nchar,char,varchar 与nvarchar区别 (收集) - chinachen 抽象类与接口区别 (收集)
virtual 与 Abstract 区别
chinachen · 2010-01-19 · via 博客园 - chinachen

 在C#的学习中,容易混淆virtual方法和abstract方法的使用,现在来讨论一下二者的区别。二者都牵涉到在派生类中与override的配合使用。

一、Virtual方法(虚方法)

     virtual 关键字用于在基类中修饰方法。virtual的使用会有两种情况:

     情况1:在基类中定义了virtual方法,但在派生类中没有重写该虚方法。那么在对派生类实例的调用中,该虚方法使用的是基类定义的方法。

     情况2:在基类中定义了virtual方法,然后在派生类中使用override重写该方法。那么在对派生类实例的调用中,该虚方法使用的是派生重写的方法。

二、Abstract方法(抽象方法)

     abstract关键字只能用在抽象类中修饰方法,并且没有具体的实现。抽象方法的实现必须在派生类中使用override关键字来实现。