Home  >  Article  >  Backend Development  >  Recommended materials for Geek Academy C# video tutorials

Recommended materials for Geek Academy C# video tutorials

黄舟
黄舟Original
2018-05-15 14:38:383065browse

"Geek Academy C# Video Tutorial" is an introductory course for the C# language. In the course, it will start from the basic concepts of the .NET platform and C#, and provide an in-depth introduction to the basic syntax, simple program logic, and Visual Studio tools of C# development. Usage techniques and implementation of commonly used algorithms. At the same time, we also hope that through course-related exercises and programming exercises, we can help students quickly get into the C# language.

Recommended materials for Geek Academy C# video tutorials

Course playback address: http://www.php.cn/course/243.html

The teacher’s teaching style:

The teacher’s lectures are simple, clear, layer-by-layer analysis, interlocking, rigorous argumentation, rigorous structure, and use the logical power of thinking to attract students’ attention Strength, use reason to control the classroom teaching process. By listening to the teacher's lectures, students not only learn knowledge, but also receive thinking training, and are also influenced and influenced by the teacher's rigorous academic attitude

The more difficult point in this video is the object-oriented feature of C#:

1. Encapsulation: We can regard anything in the world as an object, so let’s take people as an example here. One person must It's an object. So what is encapsulation? Encapsulation means that when a person wants to complete a thing, he brings all the tools he needs with him, and the required technology is also installed in his mind. This can be accomplished without the help of others. What are the benefits of this? The advantage is that if I want to ask this person to complete something, I don't need to know how he completes it, nor do I need to help him complete it. As long as I know the result, it will be OK if he completes it. As for what he does first and what he does later, I don't interfere. This will help him do it faster and better, and I will save trouble myself.

1. Access permissions (visibility)

Public: (Visible everywhere) All packages and classes are visible after importing Public

Protected: (Legal inheritance) itself, The subclasses of different packages themselves,

Private: (selfish) are only visible in this class

2,

(1), attribute-->private (Private properties, public methods, no default required)

(2), method--> public protected

The written explanation is as follows: Each object contains the information it needs to operate All information, so objects do not have to rely on other objects to complete their operations.

2. Inheritance: Taking people as an example, each of us will have some common characteristics and have to do the same things. For example: Everyone has one head, two arms, and two legs. These are common characteristics. Everyone has to eat and drink water, which is the same thing they all do. So if we now want to declare many individuals, each of them will have these characteristics, then don't I have to write a lot of repeated code? So we can first create a parent class of a person. This parent class does not represent a specific person, but is just a virtual person who has all the common characteristics of people. Next time we want to instantiate a specific person, we only need to inherit this person from the "virtual person" above, and then he will have all the common characteristics of people. In this way, we don't need to write these repeated codes.

Of course, the goal of inheritance is not only to save code, but also to achieve subsequent polymorphic functions. Beginners only need to understand that inheritance can save them a lot of code, and the rest needs to be understood slowly during the project.

The written explanation is as follows: Object inheritance represents an "is-a" relationship. If two objects A and B can be described as "B is A", then it means that B can inherit from A.

Note: If A inherits B, then A not only has all the characteristics of B except the private characteristics, but A can also have its own unique characteristics. For example, in the above example, a "virtual person" inherits. In addition to having a head, two arms, and two legs, and having to eat and drink, he may also be able to program. Programming is his unique characteristic, because not everyone can program.

1,

(1), continuation: the parent class exists, the subclass has not been overridden but can be used;

(2), new: the parent class does not, New additions to subclasses

(3), rewriting: Both parent and subclasses exist, but Fred does not meet the requirements, so the subclass redefines it;

2. Example Transformation:

(1) First, parent class, then child class, first static, then member;

When instantiating, first call the static constructor of the parent class, and then call the constructor method of the parent class , and then the construction block of the subclass calls the construction method of the subclass;

(2), the empty constructor of the parent class is called by default;

3, override

(1) Rewriting and overloading:

Rewriting: In inherited subclasses, the method signatures are the same (method name + formal parameter number type order)

                                                                               

                                                                                                                               

           Visibility of subclasses;

A. Return type: basic type and void must be the same; reference type must be

B. Exception:

C. Visibility: greater than or equal to the overridden method in the parent class

3. Polymorphism: Inheritance is necessary before polymorphism. Only when multiple classes inherit the same class at the same time can there be Polymorphism is such a statement.

Let’s take human beings as an example. We have said before that everyone has to do the same thing like “eating”. The matter of "eating" is reflected in the class as a method. Because everyone has to do it, we have written this method in "virtual people", but everyone has different ways of eating, some use chopsticks and some use forks, and some want to eat rice. Pasta. So if we want to describe the eating process of different people, we have to put this process into a specific subcategory, because everyone is different. The same method can be implemented in different subclasses. This is polymorphism. Polymorphism contributes to the flexibility of the program.

Note: If the parent class method (polymorphism) is overridden in the subclass, then this method in the parent class will not be called again.

1. Benefits:

Simplifies the programming interface. It allows the reuse of some customary names between classes without having to give a new name to each newly added function.

Simplify the code

If the function/method parameter uses the type of the parent class, you can pass in the object of the parent class or the subclass

Limitations: parent class type Variables cannot directly call subclass-specific methods. It must be forced into a variable of the subclass type in order to directly call the subclass-specific method

2. Compile-time polymorphism: In fact, it is overloading, for non-virtual members. When the system is compiled, Determine what operations to implement based on different signatures.

3. Runtime polymorphism: that is, rewriting is implemented through virtual members, which means that it is not until the system is running that the operation is decided based on the actual situation.

It is easy to understand the first case. Different signatures have different implementations

The second case is implemented on the basis of inheritance, and the subclass inherits the base class At this time, by overriding the virtual members and then using the base class to reference the subclass object, then different subclass objects implement corresponding different operations.

The benefits of this are obvious. Use the base class type to define it once, then pass it in different subclass objects, and then implement different operations, which improves efficiency.

The above is the detailed content of Recommended materials for Geek Academy C# video tutorials. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn