Copies all characters up to the first null character from an unmanaged ANSI string to a managed string, and widens each ANSI character to Unicode.
A managed string that holds a copy of the unmanaged ANSI string. If ptr is null, the method returns a null string.
Marshal.PtrToStringAnsi(IntPtr) is useful for custom marshaling or when mixing managed and unmanaged code. Because this method creates a copy of the unmanaged string's contents, you must free the original string as appropriate. This method provides the opposite functionality of the Marshal.StringToCoTaskMemAnsi(string) and Marshal.StringToHGlobalAnsi(string) methods.