How do I find the index of an object from a list in VB.NET? -
say have list, , have object. how find index of object in list?
you can use findindex find index of object in generic list: flexible method index of object.
dim list new list(of object) const myapple = "apple111" = 0 1000 list.add("apple" & i) next dim indexofmyapple = list.findindex(function(apple) (myapple.equals(apple)))
but indexof method simplier , more straightforward if want find object in list defaultequalitycomparer:
dim indexofmyapple = list.indexof(myapple)
you can use indexof
if don't know type is, .net use equals determine if 2 objects equal(should overridden not compare references).
Comments
Post a Comment