我正在编写一个允许我输入一些值的函数,然后将其作为列表返回。这是我目前的代码。
Structure question
Dim asking As String
Dim answers As List(Of String)
End Structure
Private Function addQuestionToList(toAsk As String, answers() As String) As question
addQuestionToList.asking = toAsk
Dim listTemp As List(Of String)
For i As Integer = 0 To answers.Count - 1
listTemp.Add(answers(i))
Next
addQuestionToList.answers = listTemp
End Function
#Region "Quiz Questions"
Dim GTAQuestions As List(Of question)
Sub initializeGTAQuestions()
GTAQuestions.Add(addQuestionToList("Some Question", {"answer1", "answer2"}))
End Sub
#End Region
答案 0 :(得分:0)
更改您的代码:
Dim GTAQuestions As List(问题) 子初始化GTAQuestions() GTAQuestions.Add(addQuestionToList(“Some Question”,{“answer1”,“answer2”})) 结束子
用这个:
Dim GTAQuestions As New List(Of question)
Sub initializeGTAQuestions()
GTAQuestions.Add(addQuestionToList("Some Question", {"answer1", "answer2"}))
End Sub