473,324 Members | 2,473 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,324 software developers and data experts.

Convert String to Char[]

Hi guys, i've seen it in VC++

but in C# how do i conver string to char[20]??

in c++ is like http://support.microsoft.com/?kbid=311259

Regards
Feb 28 '06 #1
6 109319
Hello, Rick!

R> but in C# how do i conver string to char[20]??

R> in c++ is like http://support.microsoft.com/?kbid=311259

Does string.ToCharArray() suit your needs?

--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com
Feb 28 '06 #2

"Rick" <el*******@hotmail.com> wrote in message
news:Oq*************@TK2MSFTNGP12.phx.gbl...
Hi guys, i've seen it in VC++

but in C# how do i conver string to char[20]??

in c++ is like http://support.microsoft.com/?kbid=311259

Regards

I'm sure there are more elegant ways, but you can simply subscript your
String object to convert character by character:

char[] myString = new char[20];

String myStuff = "My stuff";

for (int i = 0; i < myStuff.Length; i++)

{

myString[i] = myStuff[i];

}

Console.WriteLine(myString);
--
Peter [MVP Visual Developer]
Jack of all trades, master of none.
Feb 28 '06 #3
Hi Rick,

Use string.ToCharArray() method to convert.

Thanks,
Kris

Feb 28 '06 #4
it works!! Thanks a lot!!!
"Vadym Stetsyak" <va*****@ukr.net> escribio en el mensaje
news:ub**************@TK2MSFTNGP15.phx.gbl...
Hello, Rick!

R> but in C# how do i conver string to char[20]??

R> in c++ is like http://support.microsoft.com/?kbid=311259

Does string.ToCharArray() suit your needs?

--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com

Feb 28 '06 #5
Thanks a lot!!!

Rick

"Kris" <kr***********@gmail.com> escribió en el mensaje
news:11**********************@i40g2000cwc.googlegr oups.com...
Hi Rick,

Use string.ToCharArray() method to convert.

Thanks,
Kris

Feb 28 '06 #6
jejeje

that was the first option i thought
but it works with
..ToCharArray()

Thanks!!!

"pvdg42" <pv****@newsgroups.nospam> escribió en el mensaje
news:%2****************@TK2MSFTNGP10.phx.gbl...

"Rick" <el*******@hotmail.com> wrote in message
news:Oq*************@TK2MSFTNGP12.phx.gbl...
Hi guys, i've seen it in VC++

but in C# how do i conver string to char[20]??

in c++ is like http://support.microsoft.com/?kbid=311259

Regards

I'm sure there are more elegant ways, but you can simply subscript your
String object to convert character by character:

char[] myString = new char[20];

String myStuff = "My stuff";

for (int i = 0; i < myStuff.Length; i++)

{

myString[i] = myStuff[i];

}

Console.WriteLine(myString);
--
Peter [MVP Visual Developer]
Jack of all trades, master of none.

Feb 28 '06 #7

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

Similar topics

4
by: muffinman | last post by:
Hello, I try to convert a string (char or string or CString, etc) into an executable function. For example : char sample = "cout << \"sample\""; char setColor = "glColor3f(1.0f, 1.0f,...
4
by: Joe H | last post by:
Hi i converted a program to a lib. The parameters of main are maincommand(int argc, char **argv) I want to use main a s function that takes a string how can i convert a char * to a char ** or even...
3
by: Maileen | last post by:
Hi, How can we convert string^ to String or to LPCWSTR ? thx, Maileen
12
by: GRoll35 | last post by:
I get 4 of those errors. in the same spot. I'll show my parent class, child class, and my driver. All that is suppose to happen is the user enters data and it uses parent/child class to display...
3
by: David | last post by:
Hi, how to convert a char array(byte) to a string variable? byte buffer; string strTest; /*the blow codes all get type of 'buffer': System.Byte! strTest = buffer.ToString() strTest =...
1
by: TDK02 | last post by:
Hi, I need someones help to Convert C++ strings to a C-style string (char*) in VC++ 6.0. What I need to do is something as follows. There is a string as, string sh = “hello”;
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...
4
by: Man4ish | last post by:
HI , I am trying to convert string into char array of characters.but facing problem. #include <iostream> #include <string> using namespace std; int main() { string t="1,2,3,4,5,6";
2
by: slizorn | last post by:
error is as stated in the topic above: error C2440: '=' : cannot convert from 'char *' to 'char' code is below void handleOneLine(string string1) { char * cstr, *p; int counter; string...
12
by: Peter | last post by:
Trying to convert string to byte array. the following code returns byte array of {107, 62, 194, 139, 64} how can I convert this string to a byte array of {107, 62, 139, 65} ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.