What is the faster way of trying to find a single character on a String?
Posted
by vtortola
on Stack Overflow
See other posts from Stack Overflow
or by vtortola
Published on 2010-05-27T09:50:02Z
Indexed on
2010/05/27
10:01 UTC
Read the original article
Hit count: 242
Hi,
What of this code is faster/more efficient? :
Boolean contains = myString.IndexOf("~", StringComparision.InvariantCultureIgnoreCase)!=-1;
or
Boolean contains = myString.IndexOf('~')!=-1;
I think the second because is a single character, but using the invariant culture ignore case comparer is supposed to be fast too :P
Cheers.
© Stack Overflow or respective owner