06 Types and Member Bases

Source: Internet
Author: User

Accessibility of members

Do C # should all understand. Don't explain it.

Static Class
1. Static classes must derive directly from the base class System.Object, and derive no meaning from any other base class. Inheritance applies only to objects, and you cannot create instances of static classes 2. Static classes cannot implement any interface, because only one instance of the class can be used to invoke the class's interface method 3. Static classes can only define static members (fields, methods, properties, and events). Any instance member will cause the compiler to error 4. Static classes cannot be used as fields, method parameters, or local variables because they represent variables that refer to an instance, which is not allowed. The compiler detects that any such usage will be an error.

The book is easy to say.

Probably said a bit.

Static classes cannot be instantiated, cannot be inherited, and so on.

1. First, the static class is a constraint in which all the methods and fields must be static fields.

2. Static methods are classes that are called by classes, and instance methods are objects that are called by objects.

A static method or field cannot be called after the instantiation.

So he can record some kind of information.

3. Static types are recycled only after the internal process has ended, so you can also do some caching

Partial
 Public Partial class partialtest{    publicvoid  test1 () {}}publicpartial  Class  partialtest{    publicvoid  test2 () {}}var New partialtest (); O1.test1 (); O1.test2 ();

The above code is simple enough to explain the problem

Scenario Usage

  1. Source Code Control
  2. Decompose a class or struct into different logical units in the same file
  3. Code splitting

It's a kind of grammatical sugar. What the compiler does.

Component, polymorphism, and version control

Sealed classes, virtual methods, abstract classes, including interfaces that are not spoken here.

In general, it is the foundation of class design.

Design the structure from the aspects of business, performance, security, maintainability and so on.

This chapter is to lay the groundwork. Here is the only word about grammar, more understanding of design patterns, will be in the future to fill the pit.

06 Types and Member Bases

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.