From d191144a51e44e1ed983fa54a2688ab079bbe294 Mon Sep 17 00:00:00 2001 From: David Hall Date: Tue, 4 Jun 2019 16:01:43 -0600 Subject: [PATCH] Change implicit string conversion to get 'null' for IntPtr.Zero --- Core/InteropServices/StrPtr.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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.