In vb.net what would be the difference between using Items.Remove and Items.RemoveAt in the following code?
If lstCountries.SelectedIndex <> -1 Then
lstCountries.Items.RemoveAt(lstCountries.SelectedIndex)
End If
In vb.net what would be the difference between using Items.Remove and Items.RemoveAt in the following code?
If lstCountries.SelectedIndex <> -1 Then
lstCountries.Items.RemoveAt(lstCountries.SelectedIndex)
End If
the "RemoveAt" removes by index wich identifys a single object but the use of "Remove" can delete any object simlar to the one given in the parameter wich means if there is an exact object with the same propreyties it can be deleted too
removeAt takes index as parameter while remove take item as parameter. RemoveAt is faster as it directly worked over an index and perform operation while remove check all indexes to find matching item.