Imports System
Module Program
Sub WriteConcatenated(ByVal ParamArray TextArr As String())
For I As Integer = 0 To TextArr.Length - 1
For J As Integer = 0 To TextArr.Length - 1
Dim ConcatenatedText = TextArr(I) TextArr(J)
For Each Text As String In TextArr
If Text = ConcatenatedText Then
Console.WriteLine(Text)
End If
Next
Next
Next
End Sub
Sub Main(args As String())
Console.WriteLine(WriteConcatenated("five", "cents" "twenty", "twentycents"))
Console.ReadLine()
End Sub
End Module
如果存在由引數陣列的其他元素串聯而成的元素,我想將它們列印到螢屏上。
例如:上述引數陣列中第三個索引處的“twentycents”是陣列中第二個索引處的“twenty”和第一個索引處的“cents”的串聯。然后陣列的第三個元素將被列印到螢屏上。
就我而言,代碼中沒有錯誤,但是 Visual Basic 的編譯器給了我
BC30491:運算式不產生值
https://docs.microsoft.com/en-us/dotnet/visual-basic/language-reference/error-messages/expression-does-not-produce-a-value?f1url=?appId=roslyn&k=k (BC30491)(錯誤檔案)
我應該如何糾正這個錯誤?
uj5u.com熱心網友回復:
WriteConcatenated() 是一個不“回傳”值的子程式。
改變:
Console.WriteLine(WriteConcatenated("five", "cents" "twenty", "twentycents"))
到:
WriteConcatenated("five", "cents" "twenty", "twentycents")
它會起作用。
另一方面,如果WriteConcatenated()使用Function關鍵字宣告的函式使用關鍵字回傳值,則將它回傳的值Return傳遞給Console.WriteLine()您已經完成的作業。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/388605.html
上一篇:我可以使用“撥號”來選擇日期嗎?
下一篇:使用正則運算式替換特定位置的字符
