Variable has been used before it has been assigned a value

后端 未结 3 798
离开以前
离开以前 2021-01-21 15:48

I can\'t find the answer to my specific problem anywhere so I figured I\'d open a new question.

I have a program that converts text between ASCII and Binary. It does thi

3条回答
  •  长发绾君心
    2021-01-21 16:39

    Using a List(Of String) is better because you don't need to know the size of the array.
    Of course you need to initialize the List(Of String) before usage.

    Function ConvertBinaryToASCII(ByVal input As String) As String
        Dim ASCIIList() As String = .....
        Dim BinaryList() As String = ......
        Dim BinarySubstrings = Enumerable.Range(0, input.Length \ 8).[Select](Function(i) input.Substring(i * 8, 8)).ToArray()
        Dim result = new List(Of String)()
        Dim binaryMatch As Integer
    
        For Each e As String In BinarySubstrings
            binaryMatch = Array.IndexOf(BinaryList, e)
            result.Add(ASCIIList(CInt(binaryMatch)))
        Next
    
        Return String.Join("", result.ToArray())
    End Function
    

提交回复
热议问题