String length

  • Thread starter Thread starter mohammad asseedeh
  • Start date Start date
M

mohammad asseedeh

now my question is to find the length of any String manualy we will
use
a loop and this with order O(n) where n is the number of chars in the
String, now is theres a way to find the length of any String with
order one that means O(1) in one hit???!!! this is my question
 
What is wrong with the Length property on the string? It should be
pretty quick for your needs.
 
Indeed, it does exactly what he's asking for O(1). I merely reads and
actual field where the current length is always stored.

--
Andrew Faust
andrew[at]andrewfaust.com
http://www.andrewfaust.com


Nicholas Paldino said:
What is wrong with the Length property on the string? It should be
pretty quick for your needs.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

mohammad asseedeh said:
now my question is to find the length of any String manualy we will
use
a loop and this with order O(n) where n is the number of chars in the
String, now is theres a way to find the length of any String with
order one that means O(1) in one hit???!!! this is my question
 
Back
Top