public static string[] PtrToStringArray(int count, IntPtr stringArray, Encoding encoding) { if (count < 0) { throw new ArgumentOutOfRangeException("count", "< 0"); } if (encoding == null) { throw new ArgumentNullException("encoding"); } if (stringArray == IntPtr.Zero) { return(new string[count]); } string[] str = new string[count]; for (int i = 0; i < count; i++) { IntPtr intPtr = Marshal.ReadIntPtr(stringArray, i * IntPtr.Size); str[i] = UnixMarshal.PtrToString(intPtr, encoding); } return(str); }