Vb.net System.Reflection.TargetParameterCountException

Vb.net System.Reflection.TargetParameterCountException,vb.net,Vb.net,我必须为这个类编写一个程序,让我调用一个多播委托来向后写一个字符串,计算字符数和单词数。我已经把这些都整理好了,但是当我运行它时,我得到了:System.Reflection.TargetParameterCountException 我昨天才了解到代表的情况,所以可能有一些明显的事情我错过了 Private Delegate Sub Words(ByVal input As String) Sub Main() Console.Title = "Fun with words"

我必须为这个类编写一个程序,让我调用一个多播委托来向后写一个字符串,计算字符数和单词数。我已经把这些都整理好了,但是当我运行它时,我得到了:System.Reflection.TargetParameterCountException

我昨天才了解到代表的情况,所以可能有一些明显的事情我错过了

Private Delegate Sub Words(ByVal input As String)
    Sub Main()
    Console.Title = "Fun with words"
    Console.WriteLine("Type some words below.")
    Dim Input As String = Console.ReadLine()
    Dim Display As [Delegate]
    Dim Backwards As Words
    Dim Length As Words
    Dim Wordcount As Words
    Backwards = New Words(AddressOf BackwardsFunc)
    Length = New Words(AddressOf LengthFunc)
    Wordcount = New Words(AddressOf WordcountFunc)
    Display = MulticastDelegate.Combine(Backwards, Length, Wordcount)
    Display.DynamicInvoke()

    Console.ReadKey() 'end
End Sub
Sub BackwardsFunc(ByVal Input As String)
    ' Backwards
    Console.Clear()
    Console.ForegroundColor = ConsoleColor.Cyan
    Console.WriteLine(Input)
    Console.ResetColor()
    Console.WriteLine("Backwards:")
    Dim Array() As Char = Input.ToCharArray
    Dim Stack As New Stack()
    For Each element As Char In Array
        Stack.Push(element)
    Next
    For Each element As Char In Stack
        Console.WriteLine(element)
    Next
End Sub
Sub LengthFunc(ByVal Input As String)
    Console.WriteLine()
    Console.WriteLine("Length: " & Input.Length)
End Sub
Sub WordcountFunc(ByVal Input As String)
    Dim Items As String() = Input.Split(New Char() {" "c})
    Console.WriteLine()
    Console.WriteLine("Words: " & Items.Length)
End Sub
您的委托词需要一个参数,但在调用委托时您没有提供参数

调用MulticastDelegate时,还要提供代理必须使用的参数,如下所示:

Display.DynamicInvoke(Input)