G
Guest
I've developed a class in C# that implements the IList-interface because a Hashtable wasn't suitable for my task. However, I'm not sure that I developed my IList.Contains-method properly though.
The definition of IList.Contains is 'bool Contains(object value);' and the documentation states that the value is 'the object to locate in the IList'.
I was wondering what this 'value' is supposed to be. My collection contains a list of classes that each have an id-property. So, it would be easiest for me if the 'value' of 'Contains' could be this id. Can I do this or should the value be an actual instance of a class stored my collection?
I know that technically it can be anything, but are there any guidelines on what you should use? I don't want to use the id if there are other classes out there that would assume that the value is an actual instance instead of an id.
The definition of IList.Contains is 'bool Contains(object value);' and the documentation states that the value is 'the object to locate in the IList'.
I was wondering what this 'value' is supposed to be. My collection contains a list of classes that each have an id-property. So, it would be easiest for me if the 'value' of 'Contains' could be this id. Can I do this or should the value be an actual instance of a class stored my collection?
I know that technically it can be anything, but are there any guidelines on what you should use? I don't want to use the id if there are other classes out there that would assume that the value is an actual instance instead of an id.