By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,507 Members | 1,205 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,507 IT Pros & Developers. It's quick & easy.

Convert String to Char[]

P: n/a
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
Share this Question
Share on Google+
6 Replies


P: n/a
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

P: n/a

"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

P: n/a
Hi Rick,

Use string.ToCharArray() method to convert.

Thanks,
Kris

Feb 28 '06 #4

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.