Wednesday, July 19, 2006

Convert char[] to string

char[] is quite convenient if you're reading file data using StreamReader, but it doesn't offer the same functionality as string does. Here's one way I've found of converting:

char[] charBuf = new char[1024]; // Example char array
string s = ""; // Example empty
string s = new string(charBuf); // Create new string passing charBuf into the constructor

C# Programming: Convert char[] to string

Blogged with Flock

No comments: