Sunday, 21 October 2018

.NET / C# - Convert char[] to string



What is the proper way to turn a char[] into a string?



The ToString() method from an array of characters doesn't do the trick.


Answer



char[] chars = {'a', ' ', 's', 't', 'r', 'i', 'n', 'g'};
string s = new string(chars);


No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print ...