C # Basic Concepts

Source: Internet
Author: User

Proxy: the essence of proxy is to reference functions in another class. You can sort and use functions without knowing which class it comes from, as long as the function meets the same interface.

 

C #Everything in is regarded as an object.

 

The managed language is compiled into an intermediate low-level language (CLR) After the compiledCodeOr further compile the code.

The managed language is garbage collected automatically. The garbage collection language is used to release unused memory. When variables, arrays, or objects are no longer referenced, the corresponding memory space is released back to the system.

 

Each control is declared as a variable and added to a container.

 

C #Can be declared:

Public;Can be accessed by other classes

PRIVATE:The default format is not declared and can only be accessed within the class

Protected:Access

Usually declare all class variables as private and writeGetxxx, setxxxAccess the function to set and obtain data.Encapsulation Principle, Try not to allow variables in the class to be directly accessed outside the class.

 

Several methods with the same name, as long as these methods have different call parameters,Implement Overloading-Polymorphism

 

VirtualAndOverride

If there is a method in the base class and you want to overwrite it in the derived class, you should declare the method in the base classVirtualIt means that a method with the same name and parameter ID in the derived class is called, rather than a method in the base class. Must be used in a derived classOverrideKeyword to declare this method.

Base Class

Derived class

Error?

Virtual

Override

No, execute

NoneVirtual

Override

Error

Virtual

NoneOverride

Error

NoneVirtual

NoneOverride

No, warning, execute the derived class

 

When the base class method cannot be declaredVirtualThe other method to replace the method in the base class is used when the method is declared in the derived class.NewKeyword to effectively hide the methods with the same name in the base class.

For example:Public new void xxxx (){}

 

AbstractAbstract class

1Abstract methods must be in abstract classes.

2Abstract classes do not require abstract methods, but at least one abstract method is required.

3Abstract classes cannot be instantiated and can only generate Derived classes.

4Methods of an abstract class are all abstract methods. The class cannot be inherited or inherit other class hierarchies.

5The derived class of the interface must implement all methods of the interface.

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.