I’m doing some calculations of comparing two strings. In case I know they are same length, is it more expensive to call isprefix or If (“string”==”string”) ?
Share
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.
Why not test? Easy enough to use the StopWatch class to compare, and include different length strings and different compare options.
I would expect no significant difference at the core, as IsPrefix is essentially:
However there may be a difference between String’s operator == and CompareInfo class due to level of I18N applied.
In the end, you will need to measure, but I would expect that 99% of cases any difference is not significant to the overall application performance.