473,407 Members | 2,312 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,407 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 109331
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.