私はこの簡単なコードを持っています:
Public Class Form1
Dim strFriends(4) As String
Private Sub ArrayElement_Click(sender As Object, e As EventArgs) Handles ArrayElement.Click
ClearList()
'Try
For Each item As String In strFriends
lstFriends.Items.Add(item)
Next
'Catch
'End Try
End Sub
Private Sub ClearList()
lstFriends.Items.Clear()
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load
strFriends(0) = "tom"
strFriends(1) = "kate"
strFriends(2) = "bill"
strFriends(3) = "harry"
End Sub
クラス終了
try-catch が削除された場合、System.ArgumentNullException
For Each を使用するために try catch ブロックを使用することは必須ですか?