Convert String to Char[]

  • Thread starter Thread starter Rick
  • Start date Start date
Rick said:
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 = myStuff;

}

Console.WriteLine(myString);
 
jejeje

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



Thanks!!!

pvdg42 said:
Rick said:
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 = myStuff;

}

Console.WriteLine(myString);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top