[[["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-28 UTC."],[[["\u003cp\u003e\u003ccode\u003eMethodPolicy\u003c/code\u003e is a class that defines policies for RPC methods, implementing interfaces such as \u003ccode\u003eIMessage\u003c/code\u003e, \u003ccode\u003eIEquatable\u003c/code\u003e, \u003ccode\u003eIDeepCloneable\u003c/code\u003e, and \u003ccode\u003eIBufferMessage\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThe class provides constructors to create new instances, either empty or by copying another \u003ccode\u003eMethodPolicy\u003c/code\u003e object.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eMethodPolicy\u003c/code\u003e includes fields such as \u003ccode\u003eRequestPoliciesFieldNumber\u003c/code\u003e and \u003ccode\u003eSelectorFieldNumber\u003c/code\u003e, along with properties like \u003ccode\u003eDescriptor\u003c/code\u003e, \u003ccode\u003eParser\u003c/code\u003e, \u003ccode\u003eRequestPolicies\u003c/code\u003e, and \u003ccode\u003eSelector\u003c/code\u003e to manage the policies and the method they apply to.\u003c/p\u003e\n"],["\u003cp\u003eThe class has several methods for operations like calculating the size of the message, creating a deep clone, comparing equality, merging messages, and converting to string format.\u003c/p\u003e\n"],["\u003cp\u003eIt contains information about the \u003ccode\u003eRequestPolicies\u003c/code\u003e, which allows you to set policies that apply to the request message, and the \u003ccode\u003eSelector\u003c/code\u003e to determine the method these policies will be enforced on.\u003c/p\u003e\n"]]],[],null,["# Class MethodPolicy (2.17.0)\n\nVersion latestkeyboard_arrow_down\n\n- [2.17.0 (latest)](/dotnet/docs/reference/Google.Api.CommonProtos/latest/Google.Api.MethodPolicy)\n- [2.15.0](/dotnet/docs/reference/Google.Api.CommonProtos/2.15.0/Google.Api.MethodPolicy)\n- [2.10.0](/dotnet/docs/reference/Google.Api.CommonProtos/2.10.0/Google.Api.MethodPolicy)\n- [2.2.0](/dotnet/docs/reference/Google.Api.CommonProtos/2.2.0/Google.Api.MethodPolicy) \n\n public sealed class MethodPolicy : IMessage\u003cMethodPolicy\u003e, IEquatable\u003cMethodPolicy\u003e, IDeepCloneable\u003cMethodPolicy\u003e, IBufferMessage, IMessage\n\nDefines policies applying to an RPC method. \n\nInheritance\n-----------\n\n[object](https://learn.microsoft.com/dotnet/api/system.object) \\\u003e MethodPolicy \n\nImplements\n----------\n\n[IMessage](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IMessage-1.html)[MethodPolicy](/dotnet/docs/reference/Google.Api.CommonProtos/latest/Google.Api.MethodPolicy), [IEquatable](https://learn.microsoft.com/dotnet/api/system.iequatable-1)[MethodPolicy](/dotnet/docs/reference/Google.Api.CommonProtos/latest/Google.Api.MethodPolicy), [IDeepCloneable](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IDeepCloneable-1.html)[MethodPolicy](/dotnet/docs/reference/Google.Api.CommonProtos/latest/Google.Api.MethodPolicy), [IBufferMessage](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IBufferMessage.html), [IMessage](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IMessage.html) \n\nInherited Members\n-----------------\n\n[object.Equals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object-system-object)) \n[object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype) \n[object.ReferenceEquals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.referenceequals)\n\nNamespace\n---------\n\n[Google.Api](/dotnet/docs/reference/Google.Api.CommonProtos/latest/Google.Api)\n\nAssembly\n--------\n\nGoogle.Api.CommonProtos.dll\n\nConstructors\n------------\n\n### MethodPolicy()\n\n public MethodPolicy()\n\n### MethodPolicy(MethodPolicy)\n\n public MethodPolicy(MethodPolicy other)\n\nFields\n------\n\n### RequestPoliciesFieldNumber\n\n public const int RequestPoliciesFieldNumber = 2\n\nField number for the \"request_policies\" field.\n\n### SelectorFieldNumber\n\n public const int SelectorFieldNumber = 9\n\nField number for the \"selector\" field.\n\nProperties\n----------\n\n### Descriptor\n\n public static MessageDescriptor Descriptor { get; }\n\n### Parser\n\n public static MessageParser\u003cMethodPolicy\u003e Parser { get; }\n\n### RequestPolicies\n\n public RepeatedField\u003cFieldPolicy\u003e RequestPolicies { get; }\n\nPolicies that are applicable to the request message.\n\n### Selector\n\n public string Selector { get; set; }\n\nSelects a method to which these policies should be enforced, for example,\n\"google.pubsub.v1.Subscriber.CreateSubscription\".\n\nRefer to \\[selector\\]\\[google.api.DocumentationRule.selector\\] for syntax\ndetails.\n\nNOTE: This field must not be set in the proto annotation. It will be\nautomatically filled by the service config compiler .\n\nMethods\n-------\n\n### CalculateSize()\n\n public int CalculateSize()\n\n### Clone()\n\n public MethodPolicy Clone()\n\n### Equals(MethodPolicy)\n\n public bool Equals(MethodPolicy other)\n\n### Equals(object)\n\n public override bool Equals(object other)\n\n**Overrides** \n[object.Equals(object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object))\n\n### GetHashCode()\n\n public override int GetHashCode()\n\n**Overrides** \n[object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode)\n\n### MergeFrom(MethodPolicy)\n\n public void MergeFrom(MethodPolicy other)\n\n### MergeFrom(CodedInputStream)\n\n public void MergeFrom(CodedInputStream input)\n\n### ToString()\n\n public override string ToString()\n\n**Overrides** \n[object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)\n\n### WriteTo(CodedOutputStream)\n\n public void WriteTo(CodedOutputStream output)"]]