joshuadavidlee
asked on
heres a tricky question on IDictionary.Contains method
i am making new Hashtable() objects all the time in my project.
however i am making them like so :
IDictionary id = new Hashtable();
my question is in regards to both the .Contains() method in IDictionary and the.ContainsKey() method in hashtable.
according to msdn on .ContainsKey() method:
>
This method behaves exactly as Contains.
This method is an O(1) operation.
>
which potentially means that it is faster.
what i want to know is if i use the .Contains() method will it use the underlining .ContainsKey method and therefore i will get O(1) operation? and can u prove this either way.
however i am making them like so :
IDictionary id = new Hashtable();
my question is in regards to both the .Contains() method in IDictionary and the.ContainsKey() method in hashtable.
according to msdn on .ContainsKey() method:
>
This method behaves exactly as Contains.
This method is an O(1) operation.
>
which potentially means that it is faster.
what i want to know is if i use the .Contains() method will it use the underlining .ContainsKey method and therefore i will get O(1) operation? and can u prove this either way.
I just looked into the assembly and I can confirm that Contains calls the ContainsKey method.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
--Randall