[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[[["\u003cp\u003e\u003ccode\u003eGrpcPreconditions\u003c/code\u003e is a utility class in the \u003ccode\u003eGrpc.Core.Utils\u003c/code\u003e namespace designed to streamline precondition checks within code.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eCheckArgument\u003c/code\u003e methods verify conditions and throw an \u003ccode\u003eArgumentException\u003c/code\u003e if a condition is false, optionally with a custom error message.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eCheckNotNull\u003c/code\u003e methods validate if a reference is null, throwing an \u003ccode\u003eArgumentNullException\u003c/code\u003e if it is, and these methods are generic and return the reference if non-null.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eCheckState\u003c/code\u003e methods are used to ensure that the state of the application is correct, throwing an \u003ccode\u003eInvalidOperationException\u003c/code\u003e if the condition provided is false, and can also take a custom error message.\u003c/p\u003e\n"]]],[],null,["# Class GrpcPreconditions (2.66.0)\n\nVersion latestkeyboard_arrow_down\n\n- [2.66.0 (latest)](/dotnet/docs/reference/Grpc.Core/latest/Grpc.Core.Utils.GrpcPreconditions)\n- [2.63.0](/dotnet/docs/reference/Grpc.Core/2.63.0/Grpc.Core.Utils.GrpcPreconditions)\n- [2.48.0](/dotnet/docs/reference/Grpc.Core/2.48.0/Grpc.Core.Utils.GrpcPreconditions) \n\n public static class GrpcPreconditions\n\nUtility methods to simplify checking preconditions in the code. \n\nInheritance\n-----------\n\n[object](https://learn.microsoft.com/dotnet/api/system.object) \\\u003e GrpcPreconditions \n\nInherited Members\n-----------------\n\n[object.Equals(object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object)) \n[object.Equals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object-system-object)) \n[object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode) \n[object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype) \n[object.MemberwiseClone()](https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone) \n[object.ReferenceEquals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.referenceequals) \n[object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)\n\nNamespace\n---------\n\n[Grpc.Core.Utils](/dotnet/docs/reference/Grpc.Core/latest/Grpc.Core.Utils)\n\nAssembly\n--------\n\nGrpc.Core.Api.dll\n\nMethods\n-------\n\n### CheckArgument(bool)\n\n public static void CheckArgument(bool condition)\n\nThrows [ArgumentException](https://learn.microsoft.com/dotnet/api/system.argumentexception) if condition is false.\n\n### CheckArgument(bool, string)\n\n public static void CheckArgument(bool condition, string errorMessage)\n\nThrows [ArgumentException](https://learn.microsoft.com/dotnet/api/system.argumentexception) with given message if condition is false.\n\n### CheckNotNull\\\u003cT\\\u003e(T)\n\n public static T CheckNotNull\u003cT\u003e(T reference)\n\nThrows [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception) if reference is null.\n\n### CheckNotNull\\\u003cT\\\u003e(T, string)\n\n public static T CheckNotNull\u003cT\u003e(T reference, string paramName)\n\nThrows [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception) if reference is null.\n\n### CheckState(bool)\n\n public static void CheckState(bool condition)\n\nThrows [InvalidOperationException](https://learn.microsoft.com/dotnet/api/system.invalidoperationexception) if condition is false.\n\n### CheckState(bool, string)\n\n public static void CheckState(bool condition, string errorMessage)\n\nThrows [InvalidOperationException](https://learn.microsoft.com/dotnet/api/system.invalidoperationexception) with given message if condition is false."]]