diff --git a/Core/InteropServices/StrPtr.cs b/Core/InteropServices/StrPtr.cs index 464b554d..aa32764a 100644 --- a/Core/InteropServices/StrPtr.cs +++ b/Core/InteropServices/StrPtr.cs @@ -46,7 +46,7 @@ namespace Vanara.InteropServices /// Performs an implicit conversion from to . /// The instance. /// The result of the conversion. - public static implicit operator string(StrPtrAuto p) => p.ToString(); + public static implicit operator string(StrPtrAuto p) => p.IsNull ? null : p.ToString(); /// Performs an explicit conversion from to . /// The instance. @@ -96,7 +96,7 @@ namespace Vanara.InteropServices /// Performs an implicit conversion from to . /// The instance. /// The result of the conversion. - public static implicit operator string(StrPtrUni p) => p.ToString(); + public static implicit operator string(StrPtrUni p) => p.IsNull ? null : p.ToString(); /// Performs an explicit conversion from to . /// The instance. @@ -146,7 +146,7 @@ namespace Vanara.InteropServices /// Performs an implicit conversion from to . /// The instance. /// The result of the conversion. - public static implicit operator string(StrPtrAnsi p) => p.ToString(); + public static implicit operator string(StrPtrAnsi p) => p.IsNull ? null : p.ToString(); /// Performs an explicit conversion from to . /// The instance.