我对编程有点陌生,并且在完成这项工作时遇到了困难。我应该使用委托运行此代码,但我在错误之后遇到了错误。我正在使用Vb.net。谁能帮我解决这段代码中的问题吗?
Public Delegate Function D()
Dim Str As String = Console.ReadLine()
Sub Main()
Dim D1 As D
D1 = New D(AddressOf Fn1)
End Sub
Function Fn1()
System.Console.WriteLine("Please enter the string")
Dim revstr As String = StrReverse(Str)
Console.WriteLine("Reverse:")
Console.WriteLine(revstr)
Console.WriteLine("Amount of characters in the string:")
Dim Count As Integer = Str.Length
Console.WriteLine(Count)
Console.WriteLine("Amount of words in the string:")
Dim TempA() As String = Str.Split(" ")
Console.WriteLine(TempA.Length & " ")
Console.ReadKey()
End Function
感谢任何人可以提供的帮助!
您的函数 Fn1 不返回任何内容。
根据定义,函数会返回一些东西。如果你想要一个不返回任何内容的方法,你应该声明它Sub
代替Function
您的函数还应该声明返回的数据类型:
Public Function Concat(s1 As String, s2 As String) As String
return s1 & s2
End Function
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)