static string StringFromAsciiBytes(byte[] buffer, int offset, int length)
{
// Special-case for empty strings
if (length == 0)
return string.Empty;
// new string(sbyte*, ...) doesn't exist in the targeted reference assembly,
// so we first copy to an array of chars, and then create a string from that.
char[] chars = new char[length];
for (int i = 0, j = offset; i < length; i++, j++)
chars[i] = (char)buffer[j];
return new string(chars);
}