In SharePoint ID is a counter and always incremental. Even though you delete item, it is never going to occupy the blank ID. It always keeps on incrementing.
Also list.Items
always return SPListItemCollection
. But when you delete the item from List, the index of Item keeps on changing. For example, you had 10 items in list list.Items[9]
will give you the item with ID = 10
. But if you delete two items lets say ID equals 5 & 6. Than list.Items[9]
will throw an error, while list.Items[7]
will give you item with ID = 10
.
To get the item from SPListItemCollection
using ID try the following code.
SPList list = web.Lists.TryGetList("List title");
SPListItemCollection itemColl = list.Items;
SPListItem item = itemColl.GetItemById(id);
In this way you'll always get the item you require.