diff --git a/PInvoke/Shared/Handles.cs b/PInvoke/Shared/Handles.cs index b3332cad..e5f3ae4e 100644 --- a/PInvoke/Shared/Handles.cs +++ b/PInvoke/Shared/Handles.cs @@ -104,6 +104,11 @@ namespace Vanara.PInvoke /// The result of the conversion. public static implicit operator HANDLE(IntPtr h) => new HANDLE(h); + /// Performs an implicit conversion from to . + /// The h. + /// The result of the conversion. + public static implicit operator HANDLE(SafeHANDLE h) => new HANDLE(h.DangerousGetHandle()); + /// Implements the operator !=. /// The first handle. /// The second handle. @@ -1959,7 +1964,7 @@ namespace Vanara.PInvoke /// The first handle. /// The second handle. /// The result of the operator. - public static bool operator ==(SafeHANDLE h1, SafeHANDLE h2) => h1 is null || h2 is null ? false : h1.Equals(h2); + public static bool operator ==(SafeHANDLE h1, SafeHANDLE h2) => h1?.Equals(h2) ?? h2 is null; /// Determines whether the specified , is equal to this instance. /// The to compare with this instance.