Convert char array to string | .Net

Convert char array to string | .Net

Added by Nasir Mahmood updated on Friday, November 17, 2017


Previously while working on a project, I need to convert array of chars to string, I shocked to use ToString() function which return System.Char[] instead of actual string.

This is small snippet which explain how to handle such situation.


string str = "This is test";
char[] chrs = str.ToCharArray();				

Now if we use chrs.ToString() it will produce wrong output.


string result = new String(chrs);				

Above code will generate actual result as we want.

Related Tags


32 Tutorials
27 Snippets
6 Products


Contact Us

Contact us

Stay Connected