The following code simplifies code writing by representing the meta-Delegate. Different meta-representing methods will be called at runtime, and corresponding running results will be displayed.
In VB. NET, it indicates that the meta-Delegate is somewhat similar to the pointer in C language, that is, it allows the user to transmit a Process reference and then call these referenced processes. This is a powerful programming technology that allows users to call corresponding processes without the need for If or Select statements. Here, the representative element plays a bridge role.
Create a notebook. The following code is used:
Imports System
Imports System. Windows. Forms
Public Module mymodule
Delegate Sub mydele (ByVal my1 As Int32, ByVal my2 As Int32)
Sub main ()
Dim dele As mydele
Dele = AddressOf my_add
Dele. Invoke (10, 20)
Dele = AddressOf my_sub
Dele. Invoke (10, 20)
Dele = AddressOf my_mul
Dele. Invoke (10, 20)
Dele = AddressOf my_div
Dele. Invoke (10, 20)
End Sub
Public Sub my_add (ByVal num1 As Int32, ByVal num2 As Int32)
MessageBox. Show ("Add:" & (num1 + num2). ToString, "Hello", MessageBoxButtons. OK)
End Sub
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