Current location - Quotes Website - Signature design - When defining methods of classes in C#, why is there no method body? As shown in the following code, use ErpCoreModel. Framework; Use the system; National manufacturers association
When defining methods of classes in C#, why is there no method body? As shown in the following code, use ErpCoreModel. Framework; Use the system; National manufacturers association
Sorry, first of all, I have to deny the first two answers. Please don't be misled by them! This is ridiculous, guys. How to open a compiled DLL file with VS? Can you still see the source code? Are you kidding?

Please listen to me:

There are two possibilities for this situation: 1, which is an abstract method. This is a systematic method, written by Microsoft.

First of all, Microsoft doesn't open source code fairly, and the code written by Microsoft doesn't show you, so you can only see a method signature, and the method body is hidden. But I want to tell the landlord that this is definitely not a systematic method, it is an abstract method.

This is related to the core of object-oriented: encapsulation, inheritance and polymorphism. I won't talk about the big concept.

Methods without method bodies are called abstract methods. He only defined the method (method signature) and had no specific implementation (method body).

An abstract method requires its subclasses to implement the method when they inherit, that is, the parent class writes an abstract method without a method body, and the subclass inherits the parent class and then writes the method body, which is the abstract method to realize the parent class.

Another thing the landlord should pay attention to is that there can be abstract methods in ordinary classes, but only abstract methods in abstract classes. The class given by the landlord is an ordinary class.