Convert to Char[] or just use String[i]

P

pigeonrandle

Quickie time!
Is indexing using String to get individual characters 'as quick' as
converting the String to a Char[] and then using Char? Is the
conversion to Char[] worth the processing?

In advance, i thank you,
James Randle.
 
C

Christof Nordiek

Hi James,

string is like a readonly char[]. Access of individual characters from a
string should be the same as accessing them from an char[]. So the
conversion to char[] would be only extra processing and memory management,
withour any use.

Christof
 
P

pigeonrandle

Christof,

Cheers.


Christof said:
Hi James,

string is like a readonly char[]. Access of individual characters from a
string should be the same as accessing them from an char[]. So the
conversion to char[] would be only extra processing and memory management,
withour any use.

Christof

pigeonrandle said:
Quickie time!
Is indexing using String to get individual characters 'as quick' as
converting the String to a Char[] and then using Char? Is the
conversion to Char[] worth the processing?

In advance, i thank you,
James Randle.
 
M

Michael D. Ober

Converting to a Char[] and then retrieving the indexed value will retrieve a
system.Char structure. Indexing into a string returns a system.String
object. Normally, the latter is quicker since there is no copy to an array,
but sometimes you want the char result.

Mike Ober.
 

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

Top