Most efficient System.String iteration

  • Thread starter Thread starter Dennis Myrén
  • Start date Start date
D

Dennis Myrén

Hi.

There are a number of options how to iterate through the characters that
make up a System.String;
ToCharArray(), GetEnumerator or direct walkthrough from 0 to Length with
indexing.
I would like to now which one is the fastest.

Thank you.
 
Hi Dennis,

Just test which of the methods works better in your environment, ust create
a TimeSpan before executing the loop and compare it at the end.

I would say that walking through the indexing is the fastest way !!!

Cheers,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top