From 3415cac1dcbd78fe4d2e2fe0bbb7e0c17a756e23 Mon Sep 17 00:00:00 2001 From: David Hall Date: Fri, 7 Jun 2019 10:59:03 -0600 Subject: [PATCH] Added implicit operator from IntPtr --- Core/InteropServices/StrPtr.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Core/InteropServices/StrPtr.cs b/Core/InteropServices/StrPtr.cs index aa32764a..6996d839 100644 --- a/Core/InteropServices/StrPtr.cs +++ b/Core/InteropServices/StrPtr.cs @@ -53,6 +53,11 @@ namespace Vanara.InteropServices /// The result of the conversion. public static explicit operator IntPtr(StrPtrAuto p) => p.ptr; + /// Performs an implicit conversion from to . + /// The pointer. + /// The result of the conversion. + public static implicit operator StrPtrAuto(IntPtr p) => new StrPtrAuto { ptr = p }; + /// Returns a that represents this instance. /// A that represents this instance. public override string ToString() => StringHelper.GetString(ptr) ?? "null"; @@ -103,6 +108,11 @@ namespace Vanara.InteropServices /// The result of the conversion. public static explicit operator IntPtr(StrPtrUni p) => p.ptr; + /// Performs an implicit conversion from to . + /// The pointer. + /// The result of the conversion. + public static implicit operator StrPtrUni(IntPtr p) => new StrPtrUni { ptr = p }; + /// Returns a that represents this instance. /// A that represents this instance. public override string ToString() => StringHelper.GetString(ptr, CharSet.Unicode) ?? "null"; @@ -153,6 +163,11 @@ namespace Vanara.InteropServices /// The result of the conversion. public static explicit operator IntPtr(StrPtrAnsi p) => p.ptr; + /// Performs an implicit conversion from to . + /// The pointer. + /// The result of the conversion. + public static implicit operator StrPtrAnsi(IntPtr p) => new StrPtrAnsi { ptr = p }; + /// Returns a that represents this instance. /// A that represents this instance. public override string ToString() => StringHelper.GetString(ptr, CharSet.Ansi) ?? "null";