by Mwwhited
16. June 2009 15:06
Two chucks of code... both do the same thing. Why is the version with the goto so much worse? I would even debate that it is clearner.
Dim password1 As String
While True
Console.WriteLine("Enter Password: ")
password1 = ReadHiddenString()
If String.IsNullOrEmpty(password1) Then Continue While
Console.WriteLine("Reenter Password: ")
Dim password2 As String = ReadHiddenString()
If String.IsNullOrEmpty(password2) Then Continue While
If password1 <> password2 Then Continue While
Exit While
End While
GetPassword:
Console.WriteLine("Enter Password: ")
Dim password1 As String = ReadHiddenString()
If String.IsNullOrEmpty(password1) Then GoTo GetPassword
Console.WriteLine("Reenter Password: ")
Dim password2 As String = ReadHiddenString()
If String.IsNullOrEmpty(password2) Then GoTo GetPassword
If password1 <> password2 Then GoTo GetPassword