C# assign char and char array to string?

Posted by Bopha on Stack Overflow See other posts from Stack Overflow or by Bopha
Published on 2010-04-12T17:49:53Z Indexed on 2010/04/12 17:52 UTC
Read the original article Hit count: 332

Filed under:
|
|
|
        char character = 'c';
        string str = null;
        str = character.ToString();//this is ok

        char[] arrayChar = { 'a', 'b', 'c', 'd' };
        string str2 = null;
        str2 = string.Copy(arrayChar.ToString());//this is not ok
        str2 = arrayChar.ToString();//this is not ok.

I'm trying to converting char array to string, but the last two attempts don't work. Other source I found and they have to create new string type, but I don't know why. Can someone give me little explaination, thanks.

© Stack Overflow or respective owner

Related posts about c#

Related posts about char