0

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
Todd432
  • 79
  • 1
  • 5
  • 10
  • http://stackoverflow.com/questions/3211679/is-it-faster-the-listt-removet-or-listt-removeatint-method – HengChin Jul 24 '14 at 14:18
  • 3
    Doesnt your VS tell you the difference when you hold the mouse over the words offered by Intellisense? Doesnt your VS have Object Browser (View Menu -> Object Browser) to give you the definitions of anything you want?? – Ňɏssa Pøngjǣrdenlarp Jul 24 '14 at 14:20

2 Answers2

2

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

Youness
  • 1,468
  • 1
  • 9
  • 19
0

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.

Vikky
  • 752
  • 3
  • 15
  • 35