Binarysharp.MemoryManagement.Helpers.HandleManipulator.ValidateAsArgument C# (CSharp) Méthode

ValidateAsArgument() public static méthode

Validates an handle to fit correctly as argument.
public static ValidateAsArgument ( IntPtr handle, string argumentName ) : void
handle System.IntPtr A handle to validate.
argumentName string The name of the argument that represents the handle in its original function.
Résultat void
        public static void ValidateAsArgument(IntPtr handle, string argumentName)
        {
            // Check if the handle is not null
            if(handle == null)
                throw new ArgumentNullException(argumentName);

            // Check if the handle is valid
            if(handle == IntPtr.Zero)
                throw new ArgumentException("The handle is not valid.", argumentName);
        }

Same methods

HandleManipulator::ValidateAsArgument ( SafeMemoryHandle handle, string argumentName ) : void