-
Try to be as concise and easy to understand as possible, and you will understand it when you use it more.
For example, a delegate is to define a collection of function pointers, and an event is to instantiate an object of this delegate, and to this event +=event handler function, public delete void name (parameter list); Except for keywords It's a lot like a definition, which defines a function pointer. Of course, name should be treated as an object here.
public event name event;Except for keywords, it's a lot like instantiating a name object.
use, e.g. initialization.
event+=function;This is equivalent to putting the function pointer function into the event, of course, you can continue to add function1 and so on, but the function or function1 must be in the form void name (parameter list) defined by the previous delegate.
Somewhere, for example, a button is clicked, and in the button click event (in fact, this is also called over from the delegate and the event).
if(event!=null) will call function and function1;
This is the delegation Delegation is a principal, for example, you can drink water (function), I can drink water (function), but I don't know when to drink. We entrust another person, and when the time is up, the other person tells us to drink the water, and we only care about the water, not the time to drink.
Read the book a hundred times and its meaning is self-revealed, I really can't understand it, find two books to read a few times more than a dozen times, read slowly, and naturally understand.
-
For these questions, it is easy to say during the interview, but it is difficult to write them down during the written test. After a year of development, it's really bad to let me go to the written test.
-
To give you a layman's mandate is the equivalent of a real estate agent, which is entrusted to a third party when the homeowner is unwilling or has no time to execute.
An event is when a situation is met to take place.
Events are often used in conjunction with delegates.
The interface is equivalent to opening a channel for someone else.
-
Take the method as a parameter of the method (understand), the parameter should have a type, right, such as string, int, etc., then what is the type of the method, then you need to use the delegate to define the type of the method. Since the delegate is a type, it can also define the name of the variable like int, i.e., the delegate variable, and then you can assign a method to the delegate variable, and when you call the delegate variable, you can call the method assigned to it at once. Speaking of which, is it a function similar to an event, yes, maybe you should think of it, the delegate variable can not achieve the effect we want, the encapsulation is not good (look for an example, the mobile phone is very slow), so the event appears, the event declaration is similar to the declaration of the delegate variable, but there is one more event, so the role of the event is to register the method, like the delegate variable, but the encapsulation of the event is better (such as attributes).
Because a class can only inherit from one base class, but can inherit several interfaces, the function of an interface is to allow unrelated classes to inherit as well, and after inheriting, the member variables of the interface must be implemented. For example, a teacher who has obtained a driver's license is a teacher and a driver, and then the interface can be used to define the driver. By inheriting the interface, he is implemented as a driver.
It's a bit messy to write.,Personal understanding.,I hope it helps you.,I'm also learning C.
-
Conceptual attributes such as delegations, events, interfaces, inheritance, polymorphism, etc., should not be entangled in these concepts if you are a beginner. If you ask, it is estimated that it is also a vain question, and it is difficult to truly understand it if you don't go through practice.
My understanding is that a delegate is a queue of methods (a collection of ordered methods) through which events are executed, but events and delegates generally don't need to be written manually.
Interfaces are a very useful thing, very useful, and one of the three major features of object orientation. It is a kind of agreement between components, such as enforcing the structure of a class through an interface, which is difficult for you to understand, if you want to understand the beauty of it, you can learn plug-in technology or software design patterns by the way, and then frame a program by yourself, and slowly experience.
Hehe. It was a pleasure to come and talk to you about this question. First of all, I would like to know if you are learning to code for employment or personal interest? >>>More
Scope. You static char *chh;
static char *ch1;Although the address pointed to by the two pointers does not change, have you ever wondered whether the memory address they point to has been released, char chc[10]; It's local, the function is out, the lifecycle is over, and you're trying to access it with a pointer in void times(). >>>More
Understand the following rules: 1) Overloading an operator does not change the priority of the operator. >>>More
First question: What does exit failure mean? Why do you need this thing in this program? >>>More
However, it is clear that this is problematic because variable a is not assigned at all. >>>More