我必须为我的编程课编写如下所示的小型 vb.net 控制台程序。现在我必须这样做:
添加一个包含所有四个过程的多播委托。使用 DynamicInvoke() 方法调用过程。
我该怎么做?我尝试了我能想到的一切,但似乎无法弄清楚。这是我的代码。随意做任何你想做的事。任何帮助和解释表示赞赏。谢谢!
Imports System
Module Module1
Dim a, b, result as Integer
Private Delegate Sub myDelegate()
Sub Main()
Dim ask As myDelegate
ask = New myDelegate(AddressOf Ask1)
ask()
Dim Multiply1 As myDelegate
Multiply1 = New myDelegate(AddressOf Multiply)
Multiply1()
Dim Subtraction1 As myDelegate
Subtraction1 = New myDelegate(AddressOf Subtraction)
Subtraction1()
Dim Addition1 As myDelegate
Addition1 = New myDelegate(AddressOf Addition)
Addition1()
Dim Division1 As myDelegate
Division1 = New myDelegate(AddressOf Division)
Division1()
Console.ReadLine()
End Sub
Sub Ask1()
Console.WriteLine("Enter First Number")
a = Console.ReadLine()
Console.WriteLine("Enter Second Number")
b = Console.ReadLine()
End Sub
Sub Addition()
Result = a + b
Console.WriteLine("Added: " & Result)
End Sub
Sub Subtraction()
Result = a - b
Console.WriteLine("Subtracted: " & Result)
End Sub
Sub Multiply()
result = a * b
Console.WriteLine("Multiplied: " & Result)
End Sub
Sub Division()
Console.WriteLine("Divided: " & a / b)
End Sub
End Module