C # Partial keywords

Source: Internet
Author: User

Key words:

Virtual: Virtual method, itself can be instantiated, you can also override the method in a derived class;

Override: Declared when a derived class overrides a base class virtual method, avoiding potential run errors in C + +;

Abstract: The declaration of a class, abstract methods, can not be instantiated;

Sealed: Cannot be inherited class, cannot be overridden method;

Modifier:

Protected: Only itself with derived types can be accessed;

Private: can only be accessed within the owning type;

Internal: can only be accessed in the assembly that contains it;

Interface:

A syntax declaration is exactly the same as an abstract class, but does not allow the implementation of any member of the interface;

Overloaded operators are not allowed when defining interfaces;

General use IXXX (); Custom

Interface Inheritance:

Class inherits interfaces: All members and methods must be instantiated;

Interface Inheritance interface: The new interface will have all the members of the original interface and their new members;

The difference between Interface and Abstract:

Borrowing a Java distinction differs from C #, but the subject concept is similar.

Borrowing the above summary, the main difference in C # is:

1. Class cannot inherit multiple, interface can inherit multiple;

2. Members of a class can be publicly owned, and interfaces are public;

IS and as operators:

Is: Checks whether an object is compatible with the specified type and returns a Boolean value;

As: Coercion type conversion, the ability to convert to return an instance, not to return null, if (obj is ClassA) {Class A = (ClassA) obj;} merge for the same sentence: ClassA A = obj as ClassA;

C # Partial keywords

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.