C # simple steps for using Delegation,
The delegate can be understood as the function pointer in C or C ++. Calling the delegate actually calls the delegate method.
The procedure for using delegation is as follows:
1. Define Delegation
// Define the delegate use keyword delegate
Private delegate void SetProgressBarValueDelegate (int value );
2. Declare Delegation
Private SetProgressBarValueDelegate setProgressBarValue;
3. instantiate the delegate
SetProgressBarValue = new SetProgressBarValueDelegate (SetProgressBarValue1 );
SetProgressBarValue1 is the name of the delegate method. The parameter type must be consistent with the delegate type. The prototype is as follows:
// Set progress bar 1
Private void SetProgressBarValue1 (int value)
{
PgProgressBar1.Value = value;
}
4. Delegated use:
SetProgressBarValueMethod (setProgressBarValue );
// Set the progress bar value
Private void SetProgressBarValueMethod (SetProgressBarValueDelegate setProgressBarValueDelegate)
{
For (int I = 1; I <= 100; I ++)
{
Application. DoEvents ();
Thread. Sleep (50 );
SetProgressBarValueDelegate (I );
}
}
/* This Command tells the system to continue processing other events on the user interface to avoid false positives.
* Equivalent to Visual Basic 6.0 DoEvents ()
* Processing events () in easy language ()*/
Application. DoEvents ();
/* This command is used to suspend a thread (parameter: millisecond)
* If it is used in the main thread, it will lead to a false death. You can only pause it to make it clearer */
Thread. Sleep (50 );
Zookeeper
& In C Language
& Can be used as the bitwise AND or address fetch Operator
The following describes two usage methods:
1. bitwise and operation bitwise AND operator "&" are binary operators. Its function is the binary phase corresponding to the two numbers involved in the operation. The result bit is 1 only when the two binary numbers are 1. Otherwise, the result bit is 0. The number of involved operations is supplemented.
For example, 9 & 5 can be written as follows: 00001001 (Binary complement of 9) & 00000101 (Binary complement of 5) 00000001 (Binary complement of 1) Visible 9 & 5 = 1.
Bitwise AND operations are usually used to clear some bits or retain some bits. For example, if a clears the high eight bits of 0 and retains the low eight bits, it can be used as a & 255 operation (255 of the binary number is 0000000011111111 ).
2. Get the address
& As The unary operator, the result is the address of the right operation object.
For example, & x returns the address of x.
The address itself is an abstract concept used to indicate the logical location of an object in the memory.
& In C Language
& Can be used as the bitwise AND or address fetch Operator
The following describes two usage methods:
1. bitwise and operation bitwise AND operator "&" are binary operators. Its function is the binary phase corresponding to the two numbers involved in the operation. The result bit is 1 only when the two binary numbers are 1. Otherwise, the result bit is 0. The number of involved operations is supplemented.
For example, 9 & 5 can be written as follows: 00001001 (Binary complement of 9) & 00000101 (Binary complement of 5) 00000001 (Binary complement of 1) Visible 9 & 5 = 1.
Bitwise AND operations are usually used to clear some bits or retain some bits. For example, if a clears the high eight bits of 0 and retains the low eight bits, it can be used as a & 255 operation (255 of the binary number is 0000000011111111 ).
2. Get the address
& As The unary operator, the result is the address of the right operation object.
For example, & x returns the address of x.
The address itself is an abstract concept used to indicate the logical location of an object in the memory.