469,270 Members | 1,059 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,270 developers. It's quick & easy.

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 108962
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by muffinman | last post: by
4 posts views Thread by Joe H | last post: by
3 posts views Thread by Maileen | last post: by
5 posts views Thread by Zytan | last post: by
12 posts views Thread by Peter | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.