I don't really know how to explain the error... CODE:
Public Class AnagramSolver
Private inputChars() As Char
Private Sub btnSolveAnagram_Click(sender As Object, e As EventArgs) Handles btnSolveAnagram.Click
If Not input.Text.Length <= 1 Then
ReDim inputChars(input.Text.Length - 1)
For i = 1 To input.Text.Length 'puts each character from string into an array
inputChars(i - 1) = Mid(input.Text, i, 1)
Next
Else
MsgBox("The length of the anagram must be at least 2")
End If
End Sub
End Class
I use a For Next loop to step through a string and put each character into an array. But when i'm debugging with the watch window, an extra character is in every element of the array. These are the array elements in the watch window. inputted string = "james"
(0) = "j"c
(1) = "a"c
(2) = "m"c
(3) = "e"c
(4) = "s"c
I have no idea where the extra 'c' is coming from. any help?
These 'c's aren't a part of the value, it's simply the debugger's represantation of a char
.
It prints them out so you know that it's a char "j"
, not a string "j"
. As such, it has no effect to how your code works.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.