C # Programming Language Study Notes (5)

Source: Internet
Author: User

Chapter 10
1. Abstract Modifier is used to indicate that a class is incomplete and that it is intended to be used only as a base class. An abstract class differs from a nonabstract class in the following ways.
An abstract class cannot be instantiated directly, and it is a compile-time error to use New Operator on an abstract class. Although it is possible to have variables and values whose compile-time types are abstract, such variables and values will necessarily either be Null Or contain references to instances of nonabstract classes derived from the abstract types
An abstract class is permitted (but not required) to contain abstract members.
An abstract class cannot be sealed.
Abstract modifier is used to indicate that a class is not implemented. It is designed to be used only as a base class. abstract classes are different from non-abstract classes in the following aspects:
Abstract classes cannot be directly instantiated. Applying the new operator to an abstract class is a compilation error. although the variable and value types at compilation are abstract, these variables and values must either be null or store references from non-abstract class instances that inherit the abstract type.
Abstract classes can (not mandatory) contain abstract members.
Abstract classes cannot be closed.
2. When a nonabstract class is derived from an abstract class, the nonabstract class must include actual implementations of all inherited abstract members, thereby overriding those abstract members.
When a non-abstract class inherits an abstract class, a non-abstract class must contain the implementation of all inherited abstract members, so it overwrites all abstract members.
3.SealedModifier is primarily used to prevent unintended derivation, but it also enables certain run-time optimizations. in particle, because a sealed class is known to never have any Derived classes, it is possible to transform virtual function member invocations on sealed class instances into nonvirtual invocations.
The sealed modifier is mainly used to prevent unintentional inheritance, but it also optimizes runtime. in particular, because closed classes are considered not to have any inheritance classes, you can convert virtual functions in closed class instances into non-virtual functions.
4. The direct base class of a class type must not be any of the following types:System. Array,System. Delegate,System. Enum, OrSystem. valuetype.
The direct base class of a class cannot be either of the following types: system. array, system. Delegate, system. Enum, system. valuetyp.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.