473,249 Members | 1,719 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,249 software developers and data experts.

How to convert a char[] of integers to a string.

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: char[] = {0, 0, 0, 4, 5, 7}. Now I need to convert it back to a
string.

Thanks in advance for your help.

Steve

Feb 26 '07 #1
2 2320
It's so simply you're going to want to kick yourself, it's also so simple
that it's going to get overlooked.

string mystring = new string(charArray);

if you look at the overloaded constructor for the string class, you'll
notice that one of the parameters is a char array. This "should" work just
fine though I haven't toyed with it in a long time.
--

Hope this helps,
Mark Fitzpatrick
Former Microsoft FrontPage MVP 199?-2006

"Steve Kershaw" <st***********@yahoo.comwrote in message
news:11*********************@h3g2000cwc.googlegrou ps.com...
>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: char[] = {0, 0, 0, 4, 5, 7}. Now I need to convert it back to a
string.

Thanks in advance for your help.

Steve

Feb 26 '07 #2
On Feb 26, 11:47 am, "Mark Fitzpatrick" <markf...@fitzme.comwrote:
It's so simply you're going to want to kick yourself, it's also so simple
that it's going to get overlooked.

string mystring = new string(charArray);

if you look at the overloaded constructor for the string class, you'll
notice that one of the parameters is a char array. This "should" work just
fine though I haven't toyed with it in a long time.

--

Hope this helps,
Mark Fitzpatrick
Former Microsoft FrontPage MVP 199?-2006

"Steve Kershaw" <steve_kers...@yahoo.comwrote in message

news:11*********************@h3g2000cwc.googlegrou ps.com...
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: char[] = {0, 0, 0, 4, 5, 7}. Now I need to convert it back to a
string.
Thanks in advance for your help.
Steve- Hide quoted text -

- Show quoted text -
You are right! I did kick myself for overlooking the simple solution.
Thanks for your help!!!!

Steve

Feb 26 '07 #3

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

Similar topics

6
by: Markus Zeindl | last post by:
Hello, I want to write a simple encrypter, but I've got a problem: How can I convert characters into integers? I have got a string from the user, for example "Hi!". Now I get every character...
7
by: Chris Ritchey | last post by:
Hmmm I might scare people away from this one just by the title, or draw people in with a chalange :) I'm writting this program in c++, however I'm using char* instead of the string class, I am...
5
by: Sam Smith | last post by:
Hi, is there a function or a "well-known" algorithm which converts a number of random length represented as an array of bytes to its binary format? For example: a 16 byte long array:...
4
by: Vijai Kalyan | last post by:
I wrote the following function as a curiosity: template<typename SourceType, typename DestinationType> DestinationType NumericCast(const SourceType& value) { std::wstringstream strbuf; strbuf...
16
by: Dave | last post by:
Hi all, I have a 4 byte char array with the binary data for two 16-bit signed integers in it like this: Index 3 2 1 0 Data Bh Bl Ah Al Where Bh is the high byte of signed 16-bit...
24
by: djozy | last post by:
Please, how can I convert selected item from dropdown list to integer? Thank you
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 ---->...
30
by: ceeques | last post by:
Hi I am a novice in C. Could you guys help me solve this problem - I need to convert integer(and /short) to string without using sprintf (I dont have standard libray stdio.h). for...
4
by: meendar | last post by:
Hi, I am having a character pointer which contains ascii values. i just want to convert all these ascii values to respective characters and again store it in another character pointer. ...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...

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.