This is equivalent to callingnew ResourceName(template, resourceIds).ToString(), but simpler in
calling code and more efficient in terms of memory allocation.
trueif the name was parsed successfully;falseotherwise.
Remarks
Although this method returnsnullif a name is passed in which doesn't match the template,
it still throwsArgumentNullExceptionifnameis null, as this would
usually indicate a programming error rather than a data error.
[[["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\u003ePathTemplate\u003c/code\u003e is a class for representing resource name templates, handling IDs and wildcards.\u003c/p\u003e\n"],["\u003cp\u003eIt supports constructing templates from text representations, such as \u003ccode\u003eshelves/*/books/*\u003c/code\u003e, and does not handle URL encoding/decoding.\u003c/p\u003e\n"],["\u003cp\u003eThe class provides methods to expand templates with resource IDs, with or without a service name.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003ePathTemplate\u003c/code\u003e allows parsing resource names against templates and has methods to parse or attempt to parse a name and determine its success or failure.\u003c/p\u003e\n"],["\u003cp\u003eThe class contains properties for retrieving the parameter count and parameter names, even if unnamed, they will be represented as \u003ccode\u003enull\u003c/code\u003e.\u003c/p\u003e\n"]]],[],null,["# Class PathTemplate (4.10.0)\n\nVersion latestkeyboard_arrow_down\n\n- [4.10.0 (latest)](/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.PathTemplate)\n- [4.8.0](/dotnet/docs/reference/Google.Api.Gax/4.8.0/Google.Api.Gax.PathTemplate)\n- [4.4.0](/dotnet/docs/reference/Google.Api.Gax/4.4.0/Google.Api.Gax.PathTemplate)\n- [4.3.1](/dotnet/docs/reference/Google.Api.Gax/4.3.1/Google.Api.Gax.PathTemplate)\n- [4.2.0](/dotnet/docs/reference/Google.Api.Gax/4.2.0/Google.Api.Gax.PathTemplate)\n- [4.0.0](/dotnet/docs/reference/Google.Api.Gax/4.0.0/Google.Api.Gax.PathTemplate)\n- [3.2.0](/dotnet/docs/reference/Google.Api.Gax/3.2.0/Google.Api.Gax.PathTemplate) \n\n public sealed class PathTemplate\n\nRepresents a path template used for resource names which may be composed of multiple IDs. \n\nInheritance\n-----------\n\n[object](https://learn.microsoft.com/dotnet/api/system.object) \\\u003e PathTemplate \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.ReferenceEquals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.referenceequals)\n\nNamespace\n---------\n\n[Google.Api.Gax](/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax)\n\nAssembly\n--------\n\nGoogle.Api.Gax.dll\n\nRemarks\n-------\n\n\nTemplates use a subset of the syntax of the API platform. See\n\u003chttps://github.com/googleapis/googleapis/blob/master/google/api/http.proto\u003e\nfor details of the API platform.\n\n\nThis class performs no URL escaping or unescaping. It is designed for use within GRPC, where no\nURL encoding is required.\n\nConstructors\n------------\n\n### PathTemplate(string)\n\n public PathTemplate(string template)\n\nConstructs a template from its textual representation, such as `shelves/`*/books/*`*`.\n\nProperties\n----------\n\n### ParameterCount\n\n public int ParameterCount { get; }\n\nThe number of parameter segments (regular wildcards or path wildcards, named or unnamed) in the template.\n\n### ParameterNames\n\n public IReadOnlyList\u003cstring\u003e ParameterNames { get; }\n\nThe names of the parameters within the template. This collection has one element per parameter,\nbut unnamed parameters have a name of `null`.\n\nMethods\n-------\n\n### Expand(params string\\[\\])\n\n public string Expand(params string[] resourceIds)\n\nValidates that the given resource IDs are valid for this template, and returns a string representation\n\n**Remarks** \n\nThis is equivalent to calling `new ResourceName(template, resourceIds).ToString()`, but simpler in\ncalling code and more efficient in terms of memory allocation.\n\n\nThis method assumes no service name is required. Call [ExpandWithService(string, params string\\[\\])](/dotnet/docs/reference/Google.Api.Gax/latest/Google.Api.Gax.PathTemplate#Google_Api_Gax_PathTemplate_ExpandWithService_System_String_System_String___) to specify a service name.\n\n### ExpandWithService(string, params string\\[\\])\n\n public string ExpandWithService(string serviceName, params string[] resourceIds)\n\nValidates that the given resource IDs are valid for this template, and returns a string representation\n\n### ParseName(string)\n\n public TemplatedResourceName ParseName(string name)\n\nAttempts to parse the given resource name against this template, throwing [ArgumentException](https://learn.microsoft.com/dotnet/api/system.argumentexception) on failure.\n\n### ToString()\n\n public override string ToString()\n\nReturns the textual representation of this template.\n\n**Overrides** \n[object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)\n\n### TryParseName(string, out TemplatedResourceName)\n\n public bool TryParseName(string name, out TemplatedResourceName result)\n\nAttempts to parse the given resource name against this template, returning `null` on failure.\n\n**Remarks** \nAlthough this method returns `null` if a name is passed in which doesn't match the template,\nit still throws [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception) if `name` is null, as this would\nusually indicate a programming error rather than a data error."]]