What is the most efficient way to do the String comparison?
Posted
by Raj Aththanayake
on Stack Overflow
See other posts from Stack Overflow
or by Raj Aththanayake
Published on 2010-05-29T12:18:10Z
Indexed on
2010/05/29
12:22 UTC
Read the original article
Hit count: 161
c#
Hi
Both do the same thing. What is the most efficient way to compare two strings? Equals() or Compare()? Are there any differences?
if (String.Equals(StringA, StringB, StringComparison.OrdinalIgnoreCase))
{
// Your code goes here
}
if (String.Compare(StringA, StringB, true) == 0)
{
// Your code goes here
}
© Stack Overflow or respective owner