This class is used internally and by generated code; it is not particularly
expected to be used from application code, although nothing prevents it
from being used that way.
Methods
CheckNotNull<T>(T, string)
public static T CheckNotNull<T>(T value, string name) where T : class
Throws an ArgumentNullException if the given value is null, otherwise
return the value to the caller.
[[["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-08-07 UTC."],[[["\u003cp\u003e\u003ccode\u003eProtoPreconditions\u003c/code\u003e is a static class within the \u003ccode\u003eGoogle.Protobuf\u003c/code\u003e namespace, offering helper methods for exception handling when preconditions fail.\u003c/p\u003e\n"],["\u003cp\u003eThe class is primarily intended for internal use and by generated code, although it can technically be used in application code.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eProtoPreconditions\u003c/code\u003e inherits from the base \u003ccode\u003eobject\u003c/code\u003e class, inheriting its standard methods, such as \u003ccode\u003eEquals\u003c/code\u003e, \u003ccode\u003eGetHashCode\u003c/code\u003e, and \u003ccode\u003eToString\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThe class contains the \u003ccode\u003eCheckNotNull<T>(T value, string name)\u003c/code\u003e method, which verifies if a provided value is not null and throws an \u003ccode\u003eArgumentNullException\u003c/code\u003e if it is, returning the value otherwise.\u003c/p\u003e\n"],["\u003cp\u003eThere are multiple versions of \u003ccode\u003eProtoPreconditions\u003c/code\u003e, with version 3.27.1 being the latest release.\u003c/p\u003e\n"]]],[],null,["# Class ProtoPreconditions (3.27.1)\n\nVersion latestkeyboard_arrow_down\n\n- [3.27.1 (latest)](/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.ProtoPreconditions)\n- [3.23.0](/dotnet/docs/reference/Google.Protobuf/3.23.0/Google.Protobuf.ProtoPreconditions)\n- [3.15.8](/dotnet/docs/reference/Google.Protobuf/3.15.8/Google.Protobuf.ProtoPreconditions) \n\n public static class ProtoPreconditions\n\nHelper methods for throwing exceptions when preconditions are not met. \n\nInheritance\n-----------\n\n[object](https://learn.microsoft.com/dotnet/api/system.object) \\\u003e ProtoPreconditions \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[Google.Protobuf](/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf)\n\nAssembly\n--------\n\nGoogle.Protobuf.dll\n\nRemarks\n-------\n\nThis class is used internally and by generated code; it is not particularly\nexpected to be used from application code, although nothing prevents it\nfrom being used that way.\n\nMethods\n-------\n\n### CheckNotNull\\\u003cT\\\u003e(T, string)\n\n public static T CheckNotNull\u003cT\u003e(T value, string name) where T : class\n\nThrows an ArgumentNullException if the given value is null, otherwise\nreturn the value to the caller."]]