. NET Object-oriented Foundation

Source: Internet
Author: User

Some concepts of object-oriented basics:
Recursion: The result of a method by invoking itself directly or indirectly. (recursion must have a termination condition)
Object communication: Data interaction with objects of other classes in the behavior of an object (note: Object He's the new addition to the program's coupling)

Three elements of a collection: The combination of type, element, and primer.
The advantages of the array: Fast reading speed, easy to query (query convenience and array storage location)
Disadvantages of arrays: fixed length, moving data is a cascade of data changes
The advantages of the collection: the length is not fixed, each time the collection can not accommodate, the collection will create a new four-step memory (new memory refers to: on the existing memory based on the addition of a step to four)

Generics: Some classes cannot be used alone, it relies on one or more types, but when the class is defined, it cannot predict which type to rely on, and this situation can be used generics.
Definition of generics < type 1, type 2,......, type n>

Delete the specified location element:
Cases:
M RemoveAt (0) Delete an element with an index of 0
M Remove (2) removes the first element in the collection that is encountered with a number 2

Emptying the collection:
Example Nums. Clear ();

Find:
Example Nums. Contaions (3) Find the number in the collection 3

Set counter-diversion: Reverse

Foeeach Cycle:
foreach (type variable name in collection) {}
Type must match the type of the element in the collection
The Foreach loop is also called a system loop because the collection cannot be changed in the loop body (change the set: Change the size or order of the collection)

Fully qualified name: namespace. Class Name

Dictionary:dictionarg<key,value>
Dictionary features: Key values in a dictionary must be unique


Object communication: Associations generated by behavior
Object relationship: Refers to the association of a normal between two objects

Object relationships:

Describe object relationships should be in the same context
Object relationships: One-to-one relationships, a-to-many relationship (multi-pair), many-to-many relationships

Describe relationships
One-to-one relationship: a corresponds to a B, a B corresponds to a a,a and B is a pair of relations

One-to-many (many-to-one) relationship: A (1 a) corresponds to multiple B (1 B), a B (1 B) corresponds to a (multiple a), A and B are one-to-many (many-to-one) relationships

Many-to-many relationships: a corresponds to multiple B, a B to multiple a,a and B is a many-to-many relationship

Object relationships are represented in code with attributes. This property holds a reference to another object

Many-to-many relationships: typically hold a single reference to another class in two classes
One-to-many (multi-pair) relationship: typically hold a reference to a single class on a multiple end, and hold a collection reference at one of the few ends (can be a value written at one end of a reference)
Many-to-many relationships: Holding collection references at both ends

Attention:
If an error occurs: The object reference is not set to an instance of the object (this error usually occurs when using a null-referred object Resource)

constructor function:
1. Logically it is an object that should be done when it comes to doing something to make the object realistic.
2. Technically it is an initializer, through which it can generate object resources
3. When the point-in-time object is created

Assign a value to a property: To ensure that the object is meaningful in the real world

Constructor Writing Specification:
Modifier class name (argument list) {
Structural body
}
Note: The class name of the constructor can only write the current class name

constructor function:
Occurrence point in time: when objects are common
When you're done: Initialize the data, which is realistic, and it has a default parameterless constructor when the definition constructor is not displayed in the class.

The display constructor is your own manual common constructor.
Note: The default parameterless constructor disappears when a constructor is defined in the class with a display

Design construction parameters should try to avoid the caller may appear to give incorrect merits, but also should make the calling method as simple as possible


This keyword:
This: Represents the current object, whose type is the type of the current object
Object initializer, you must ensure that the class has no parameter constructors
When the parameter name, field, and property name are the same in a method body, the fields and properties are overwritten in the method.

. NET Object-oriented Foundation

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.