Count object list duplicates

I’m making an inventory using a List, where Item is a class with a few variables. My inventory GUI is showing various buttons of the same item, and I want to count the items that are duplicates and show one button for that item with a number showing how much of it the player has. The problem is that the item is an object, so all keys in the List are named Item, I need to compare using Item.itemID. itemID is a variable inside the Item class.
Here’s an image that shows how it is:

And here’s one showing how I want:

This post is a bit old, but I’ll answer. You need to rethink how duplicate items should be handled. Add a counter to the item’s script. Instead of having 6 separate copies of the same item in the same list, you’ll have one item with a count of 6. Upon pickup, have a method that compares the ID of a newly added item to the existing inventory. If the item already exists, increment that item’s counter; otherwise, add it to the list as a new item. Then just display the count on the item’s icon.

This would be the same principle as something that has “durability”; the only real difference is how you display and interpret it.