Is there any difference between
if(string.Empty.Equals(text))
and
if(text.Equals(string.Empty))
concerning performance, unexpected behaviour or readability?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
These will have the same performance characteristics.
If
textisnull, your second line with throw aNullReferenceException.Personally I find:
More readable than either your options.
And there are the built in:
And for .NET 4.0: