简体   繁体   中英

How to convert string “brakemeup” in to char[stringlength] array?

if i have this code, how can i put alle the chars in my string in to the Char array?

i know this wont compile but the logic shows what im trying to do.

    private void button1_Click(object sender, EventArgs e)
    {
        string stringX = textbox1.Text;

        int strlen = stringX.Length();

        char[] arrayX = new char[strlen];

        arrayX = stringX.Split("");    
    }

Just use the ToCharArray method

private void button1_Click(object sender, EventArgs e)
{
    string stringX = textbox1.Text;

    char[] arrayX = stringX.ToCharArray();    
}
char[] arrayX = textbox1.Text.ToCharArray();

怎么样

stringX.ToCharArray() 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM