473,385 Members | 2,162 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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

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

In advance, i thank you,
James Randle.

Jan 15 '07 #1
4 1451
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" <pi**********@hotmail.comschrieb im Newsbeitrag
news:11*********************@l53g2000cwa.googlegro ups.com...
Quickie time!
Is indexing using String[i] to get individual characters 'as quick' as
converting the String to a Char[] and then using Char[i]? Is the
conversion to Char[] worth the processing?

In advance, i thank you,
James Randle.

Jan 15 '07 #2
Christof,

Cheers.
Christof Nordiek wrote:
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" <pi**********@hotmail.comschrieb im Newsbeitrag
news:11*********************@l53g2000cwa.googlegro ups.com...
Quickie time!
Is indexing using String[i] to get individual characters 'as quick' as
converting the String to a Char[] and then using Char[i]? Is the
conversion to Char[] worth the processing?

In advance, i thank you,
James Randle.
Jan 15 '07 #3
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.

"pigeonrandle" <pi**********@hotmail.comwrote in message
news:11*********************@l53g2000cwa.googlegro ups.com...
Quickie time!
Is indexing using String[i] to get individual characters 'as quick' as
converting the String to a Char[] and then using Char[i]? Is the
conversion to Char[] worth the processing?

In advance, i thank you,
James Randle.



Jan 16 '07 #4
"Michael D. Ober" <obermd.@.alum.mit.edu.no.spamwrote in message
news:hG******************@newsread2.news.pas.earth link.net...
Indexing into a string returns a system.String object.
That is not true.
Indexing into a string returns a char

Bill

Jan 16 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Jim | last post by:
I have to access a third party api to work with their hardware. Everything was going great UNTIL I ran into the problem of C# char being 16 bits and the C char being 8 bits. I cannot seem to...
7
by: MilanB | last post by:
Hello How to convert char to int? Thanks
12
by: Brian Henry | last post by:
first question... I have a flat file which unfortinuatly has columns seperated by nulls instead of spaces (a higher up company created it this way for us) is there anyway to do a readline with this...
14
by: Drew | last post by:
Hi All: I know I am missing something easy but I can't find the problem! I have a program which reads an integer as input. The output of the program should be the sum of all the digits in the...
20
by: Niyazi | last post by:
Hi all, I have a integer number from 1 to 37000. And I want to create a report in excel that shows in 4 alphanumeric length. Example: I can write the cutomerID from 1 to 9999 as: 1 ---->...
10
by: sposes | last post by:
Im very much a newbie but perhaps somehone can help me. Ive been searching for a way to convert a std::string to a unsigned char* The situation is I have a function that wants a unsigned char*...
6
by: compboy | last post by:
Can anyone help me about this. I have been trying all the ways I knew and I could find but just didnt work. I have tried: using itoa but it says that it doesnt have that function. and...
2
by: Joah Senegal | last post by:
Hello I need to convert a chat to a string... but I don't know how to do this. i;ve searched the internet but I've only find some code to convert char * to string or char to string.... but I...
2
by: Steve Kershaw | last post by:
I can convert from a string to a char array (char) by using string.ToCharArray() function. Now how do I convert it back? The string looks like this: "000457". I've converted it to a char array:...
5
by: Zytan | last post by:
I am surprised that a single character string is not auto-created from a single char. It is hard to find information on converting a char into a string, since most people ask how to convert char...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.