I’m using them alternately. Is there a difference between them?
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.
On the surface they would seem functionally identical, but the main difference is:
Lengthis a property that is defined of strings and is the usual way to find the length of a string.Count()is implemented as an extension method. That is, whatstring.Count()really does is callEnumerable.Count(this IEnumerable<char>), aSystem.Linqextension method, given thatstringis really a sequence ofchars.Performance concerns of LINQ enumerable methods notwithstanding, use
Lengthinstead, as it’s built right into strings.