"C # Illustrated Tutorial" Four reading notes: Classes and inheritance

Source: Internet
Author: User

This article has been included in the "C # Illustrated Tutorial" Reading Notes directory sticker, click to access the directory for more content.

One, the universe: Object

(1) Except for the special Object class, all other classes are derived classes, even if they do not display the base class definition.

(2) A derived class can have only one base class, called single inheritance .

Second, base class that Thing

(1) How do I access a base class member in a derived class? Use the base keyword, such as base. Field1;

(2) How do I block a method or member in a base class? Use the New keyword before the member definition defined by the derived class;

(3) How do I use a reference to a base class? You can use the Richter substitution rule to create a base class object that points to a derived class.

The small character has University Q: member access modifier

(1) Public: All classes, including the internal and external classes of the assembly, can be accessed with no restrictions;

(2) Private: can only be accessed by members of his own class;

(3) Protected: Allows members of their own class and members of derived classes that inherit from the class to access;

(4) Internal: visible to all classes within the assembly;

(5) Protected internal: visible to all members of derived classes that inherit from the class and to classes inside all assemblies;

Iv. Sealing class and Static class

(1) Sealed class: Cannot be inherited, need to use sealed modifier;

(2) Static class:

All members of the ① class must be static;

The ② class can have a static constructor, but cannot have an instance constructor;

③ Static class is implicitly sealed and cannot be inherited;

V. Extension methods and Naming conventions

(1) Extension method: Allows you to write a method that is associated with a class other than the class that declares it.

The extension method requires three points: the class that declares the extension method must be a static class ①;

The ② extension method itself must also be a static method;

The ③ parameter must include the This keyword, followed by the name of the class it extends;

(2) Naming convention: ①pascal case, ②camel case, ③ underline and camel case;

Vi. Mind Mapping of this chapter

Attachment

Mind Mapping (JPG, PDF, and mmap files): Http://pan.baidu.com/s/1i3qmVfZ

Zhou Xurong

Source: http://www.cnblogs.com/edisonchou/

The copyright of this article is owned by the author and the blog Park, welcome reprint, but without the consent of the author must retain this paragraph, and in the article page obvious location to give the original link.

"C # Illustrated Tutorial" Four reading notes: Classes and inheritance

Related Article

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.