下面的代码片段在用 0 填充最后一部分时会引发错误,最后一部分是 008、009、018、019、028、029 等。有人知道为什么吗?
Sub Main()
Dim fixed As String = "192.168.0."
Dim ip1, ip2 As String
For i As Int32 = 1 To 255
ip1 = fixed & Convert.ToString(i)
Console.Write(ip1 & " - ")
Try
Console.WriteLine(My.Computer.Network.Ping(ip1))
Catch ex As Exception
Console.WriteLine(ex.Message)
End Try
ip2 = fixed & Convert.ToString(i).PadLeft(3, "0"c)
Console.Write(ip2 & " - ")
Try
Console.WriteLine(My.Computer.Network.Ping(ip2))
Catch ex As Exception
Console.WriteLine(ex.Message)
End Try
Next
End Sub