C# collection/string .Contains vs collection/string.IndexOf
Posted
by Daniel
on Stack Overflow
See other posts from Stack Overflow
or by Daniel
Published on 2010-05-14T01:38:22Z
Indexed on
2010/05/14
1:44 UTC
Read the original article
Hit count: 484
Is there a reason to use .Contains on a string/list instead of .IndexOf? Most code that I would write using .Contains would shortly after need the index of the item and therefore would have to do both statements. But why not both in one?
if ((index = blah.IndexOf(something) >= 0) // i know that Contains is true and i also have the index
© Stack Overflow or respective owner