A virtual event declaration specifies that the accessors of that event are
virtual. The virtual modifier applies
to both accessors of an event.
An abstract event declaration specifies that the accessors of the event are
virtual, but does not provide an
actual implementation of the accessors. Instead, non-abstract derived
classes are required to provide their own
implementation for the accessors by overriding the event. Because an
accessor for an abstract event declaration
provides no actual implementation, its accessor-body simply consists of a
semicolon.
Chapter 17 Classes
251
An event declaration that includes both the abstract and override modifiers
specifies that the event is
abstract and overrides a base event. The accessors of such an event are
also abstract.
Abstract event declarations are only permitted in abstract classes (§17.1.1.
1).
The accessors of an inherited virtual event can be overridden in a derived
class by including an event declaration
that specifies an override modifier. This is known as an overriding event
declaration. An overriding event
declaration does not declare a new event. Instead, it simply specializes
the implementations of the accessors of an
existing virtual event.
An overriding event declaration must specify the exact same accessibility
modifiers, type, and name as the
overridden event.
An overriding event declaration may include the sealed modifier. Use of
this modifier prevents a derived class
from further overriding the event. The accessors of a sealed event are also
sealed.
It is a compile-time error for an overriding event declaration to include a
new modifier.
Except for differences in declaration and invocation syntax, virtual,
sealed, override, and abstract accessors
behave exactly like virtual, sealed, override and abstract methods.
Specifically, the rules described in §17.5.3,
§17.5.4, §17.5.5, and §17.5.6 apply as if accessors were methods of a
corresponding form. Each accessor
corresponds to a method with a single value parameter of the event type, a
void return type, and the same
modifiers as the containing event.
分享到:
相关推荐
C# 中的 new、abstract、virtual、override、sealed 关键字的区别和使用代码示例 摘要:本资源旨在对 C# 中的 new、abstract、virtual、override、sealed 关键字进行详细的解释和比较,并提供实践代码示例,以帮助...
《Java开发工具包(JDK)17.0.4 for Windows 64位详解》 Java Development Kit(JDK)是Oracle公司发布的用于开发和运行Java应用程序的软件开发工具包。本文将深入探讨JDK 17.0.4这一特定版本,尤其关注其在Windows...
标题中的“jdk-17.0.4_windows-x64_bin.exe.zip”表明这是一个Java Development Kit(JDK)的安装程序,版本号为17.0.4,针对Windows操作系统,且是64位版本。这个文件以.zip格式压缩,通常用于减小文件大小以便于...
Oracle的JDBC驱动包是Java开发者连接Oracle数据库的重要工具,它允许Java应用程序通过JDBC(Java Database Connectivity)接口与Oracle数据库进行交互。JDBC是一种Java API,由Sun Microsystems(现已被Oracle公司...
4. 输出供电:会介绍如何为输出模块供电,包括电源类型、供电电压、供电方式等。 5. 检查IP67 Sealed I/O模块的供电电压:这部分内容会指导用户如何检测模块的供电电压是否正确。 6. Fipio总线的布线和长度检查:...
4. **增强安全**:通过将敏感数据的管理整合到cdk8s中,可以更好地遵循安全最佳实践,例如限制对解密密钥的访问,以及对Sealed Secrets的生命周期进行严格控制。 在cdk8s-sealed-secrets-controller-0.0.1这个版本...
14. abstract 与 virtual、override: abstract 与 virtual 一起用于定义抽象方法;abstract 与 override 不兼容,因为抽象方法没有实现,无需重写。 15. 接口成员: 接口可包含方法、属性、索引器和事件,但无...
2. **新功能**:JDK 17引入了多个新特性,例如密封类(Sealed Classes)、记录类(Record Classes)、开关表达式增强(Switch Expressions Improvements)、loom项目中的结构化并发等。这些特性旨在提高代码的清晰度...
14. abstract与virtual/override:abstract不能与virtual同时使用,因为abstract已表示没有实现;但abstract可以与override组合,因为子类必须实现抽象方法。 15. 接口成员:接口可包含方法、属性、索引器和事件,...
标题中的“jdk-17.0.4_macos-aarch64_bin.dmg.zip”指的是Java Development Kit(JDK)的版本17.0.4,这是一个专为苹果Mac OS操作系统上的ARM64架构(也称为AArch64或Apple Silicon)编译的二进制发行版。...
正确使用`virtual`、`override`、`abstract`、`sealed`和`new`关键字,可以确保代码的灵活性和可维护性。在实际编程中,应根据需求选择合适的关键字,并注意避免隐藏父类方法,以保持代码的清晰和可预测性。
4. Delegate关键字 Delegate关键字用于声明委托类型,委托类型是一种可用于封装命名或匿名方法的引用类型。例如: public delegate void TestDelegate(string message); 5. Interface关键字 Interface关键字用于...
标题 "jdk-17.0.4_linux-x64_bin.tar.gz.zip" 指的是一个Java Development Kit(JDK)的压缩包文件,版本号为17.0.4,适用于Linux 64位操作系统。这个文件是通过将原本的 ".tar.gz" 文件进一步压缩成 ".zip" 格式,...
4.abstract 是什么意思? 5.internal 修饰符起什么作用? 6.sealed 修饰符是干什么的? 7.override 和 overload 的区别? 8.什么是索引指示器? 9.new 修饰符是起什么作用? 10.this 关键字的含义? 11.可以使用抽象...
Sealed-bidCombinatorialDesigns...................161 7.5.2 TwoCombinatorialAscendingAuctionDesigns........165 7.6 TheNeedforBidder-aideTools.............................172 7.7 Conclusions...............
protected virtual void OnPropertyChanged(string propertyName) { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); } } ``` #### 4. 建造者模式 建造者模式将复杂对象的构建过程...
标题中的"jdk-17.0.4_linux-aarch64_bin.tar.gz.zip"表明这是一个Java Development Kit(JDK)的软件包,版本为17.0.4,专为基于ARM架构(aarch64)的Linux系统设计。这个软件包采用双重压缩格式,首先是`.tar`,它...
4.abstract 是什么意思? 5.internal 修饰符起什么作用? 6.sealed 修饰符是干什么的? 7.override 和 overload 的区别? 8.什么是索引指示器? 9.new 修饰符是起什么作用? 10.this 关键字的含义? 11.可以使用抽象...
Visual.Assist.X.V10.6.1901的Crack破解补丁. 2012.02.28(General release.) 增加了对 Visual Studio 2011 Beta 的初步... 提升了对于C++语言的 abstract, override, sealed, and final 的解析表现; 等等......