N
niteshs
Hello all, just checking which method is faster
string A;
A = "";
if (A == string.Empty)
{
MessageBox.Show("a is empty");
}
else
{
MessageBox.Show("a is not empty");
}
//or is this quicker
if (A.Equals(""))
{
MessageBox.Show("a is empty");
}
else
{
MessageBox.Show("a is not empty");
}
The argument here is in the first method we are using the string
property empty and then the equality == and in scenario 2 we are using
the object method equals to compare(so inside == we are calling Equals,
make sense, is == overloading Equals() ?), thus which 1 is
quicker...debating this with sum1 so we tht we'd post it here
hope we on the right track...
chow
string A;
A = "";
if (A == string.Empty)
{
MessageBox.Show("a is empty");
}
else
{
MessageBox.Show("a is not empty");
}
//or is this quicker
if (A.Equals(""))
{
MessageBox.Show("a is empty");
}
else
{
MessageBox.Show("a is not empty");
}
The argument here is in the first method we are using the string
property empty and then the equality == and in scenario 2 we are using
the object method equals to compare(so inside == we are calling Equals,
make sense, is == overloading Equals() ?), thus which 1 is
quicker...debating this with sum1 so we tht we'd post it here
hope we on the right track...
chow