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,
 
Back
Top