C # basic knowledge 2,

Source: Internet
Author: User

C # basic knowledge 2,

C # basic knowledge 2

1. static fields and static members: they are shared by all instances of the class and changed to be visible to all instances.

2. Fields, methods, attributes, constructors, operators, and events declared as static.

3. constants are different from static constants: constants do not have their own storage locations and are replaced by compilers during compilation.

4. Different class attributes and class fields: a property is a function member that does not allocate memory for data storage and execute code.

5. All paths of the get accessors must contain a return statement and return a value of the attribute type.

6. An Instance constructor is a special method that is executed when an instance is created. It is used to initialize the instance state and declared as public unless you want to create a singleton mode and declare it as private.

7. The constructor name is the same as the class name and cannot return values.

8. The constructor does not contain parameters by default, and the method body is empty. User-Defined parameters can be reloaded

9. When a user-defined constructor is used, the default zero-parameter constructor is unavailable. To use a user-defined zero-parameter constructor.

10. Static constructor: only one class can have one, but it cannot contain parameters or access modifiers.

11. The static constructor cannot display calls from the program and is automatically called by the system. It occurs before the class instance is created and before the class static member is referenced.

12. object initialization list: the member must be public in the object to be created. Initialization takes place after the constructor is complete.

13. Only one non-hosted resource can be cleared or released before the Destructor execution instance is destroyed. It cannot contain parameters or access modifiers, it has the same name as the class but uses "~" Prefix: it only applies to the instance. There is no static destructor and you cannot explicitly call the destructor in the code.

14. The Destructor should only release the external resources of the object and should not access other objects.

15. Difference Between the Const field and readonly field: the former value is determined during the compilation period, and the latter can be determined during the runtime.

16. Scope of use of This keyword: instance accessors for instance constructors, instance methods, attributes, and indexes.

17. Declared index: The index name is this, and the parameter list is in the middle of square brackets. There must be at least one parameter.

18. Duplicate indexes in the class must have different parameter lists.

19. Access modifiers of accessors: only when Members have both get and set can they have access modifiers, but only one can have access modifiers.

20. Division class: Same as the general class declaration, except for the additional type modifier partial.

21. division method: Define the Declaration to provide the signature and return type, and the Implementation part is only a semicolon; implement the Declaration to provide the signature, return type, and normal form of statement block implementation.

22. The division method declares that the signature cannot contain modifiers, And the return type must be void. The parameter list cannot contain the out parameter.

23. The division method can have a defined part but not an implemented part. The implementation part must have a definition part.

24. class inheritance: extends existing classes. Existing classes are base classes. The new class is called a derived class ).

25. The object class is a base class and the only non-derived class. All other classes are derived classes.

26. A class can only inherit from each other. There is no limit on the hierarchy of inheritance.

27. Hide the data members of the base class in the derived class: declare new members of the same type and use the same name.

28. Hide the function members of the base class in the derived class: declare a new function member with the same signature. A signature consists of a name and a parameter list, excluding the return type.

29. to hide a member in a derived class, add new to the new member to let the compiler know that you intentionally hidden the member.

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.