public ServiceName(string projectId, string locationId, string namespaceId, string serviceId)
Constructs a new instance of a ServiceName class from the component parts of pattern
projects/{project}/locations/{location}/namespaces/{namespace}/services/{service}
Formats the IDs into the string representation of this ServiceName with pattern
projects/{project}/locations/{location}/namespaces/{namespace}/services/{service}.
Formats the IDs into the string representation of this ServiceName with pattern
projects/{project}/locations/{location}/namespaces/{namespace}/services/{service}.
If true will successfully store an unparseable resource name into the UnparsedResource
property; otherwise will throw an ArgumentException if an unparseable resource name is
specified.
If true will successfully store an unparseable resource name into the UnparsedResource
property; otherwise will throw an ArgumentException if an unparseable resource name is
specified.
[[["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\u003eThis document provides reference documentation for the \u003ccode\u003eServiceName\u003c/code\u003e class within the Google Cloud Build v2 API, used to represent a resource name for the \u003ccode\u003eService\u003c/code\u003e resource.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eServiceName\u003c/code\u003e class, inheriting from \u003ccode\u003eobject\u003c/code\u003e and implementing \u003ccode\u003eIResourceName\u003c/code\u003e and \u003ccode\u003eIEquatable\u003c/code\u003e, encapsulates the pattern \u003ccode\u003eprojects/{project}/locations/{location}/namespaces/{namespace}/services/{service}\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eConstructors and methods are available for creating, formatting, parsing, and validating \u003ccode\u003eServiceName\u003c/code\u003e instances, ensuring they adhere to the required resource name pattern, along with getting the different parts of the resource name.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eServiceName\u003c/code\u003e class includes properties to access individual components of the resource name such as \u003ccode\u003eProjectId\u003c/code\u003e, \u003ccode\u003eLocationId\u003c/code\u003e, \u003ccode\u003eNamespaceId\u003c/code\u003e, and \u003ccode\u003eServiceId\u003c/code\u003e, as well as methods for handling both parsed and unparsed resource names.\u003c/p\u003e\n"],["\u003cp\u003eThe available versions of the Service Name documentation are 1.0.0, 1.1.0, 1.2.0, 1.3.0, and 1.4.0, with 1.4.0 being the latest.\u003c/p\u003e\n"]]],[],null,["# Cloud Build v2 API - Class ServiceName (1.4.0)\n\nVersion latestkeyboard_arrow_down\n\n- [1.4.0 (latest)](/dotnet/docs/reference/Google.Cloud.CloudBuild.V2/latest/Google.Cloud.CloudBuild.V2.ServiceName)\n- [1.3.0](/dotnet/docs/reference/Google.Cloud.CloudBuild.V2/1.3.0/Google.Cloud.CloudBuild.V2.ServiceName)\n- [1.2.0](/dotnet/docs/reference/Google.Cloud.CloudBuild.V2/1.2.0/Google.Cloud.CloudBuild.V2.ServiceName)\n- [1.1.0](/dotnet/docs/reference/Google.Cloud.CloudBuild.V2/1.1.0/Google.Cloud.CloudBuild.V2.ServiceName)\n- [1.0.0](/dotnet/docs/reference/Google.Cloud.CloudBuild.V2/1.0.0/Google.Cloud.CloudBuild.V2.ServiceName) \n\n public sealed class ServiceName : IResourceName, IEquatable\u003cServiceName\u003e\n\nReference documentation and code samples for the Cloud Build v2 API class ServiceName.\n\nResource name for the `Service` resource. \n\nInheritance\n-----------\n\n[object](https://learn.microsoft.com/dotnet/api/system.object) \\\u003e ServiceName \n\nImplements\n----------\n\n[IResourceName](https://github.com/googleapis/gax-dotnet/blob/83f42b5edc4529818dbdb34d9ea9ecc3c04f7b6e/Google.Api.Gax/IResourceName.cs), [IEquatable](https://learn.microsoft.com/dotnet/api/system.iequatable-1)[ServiceName](/dotnet/docs/reference/Google.Cloud.CloudBuild.V2/latest/Google.Cloud.CloudBuild.V2.ServiceName) \n\nInherited Members\n-----------------\n\n[object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype)\n\nNamespace\n---------\n\n[Google.Cloud.CloudBuild.V2](/dotnet/docs/reference/Google.Cloud.CloudBuild.V2/latest/Google.Cloud.CloudBuild.V2)\n\nAssembly\n--------\n\nGoogle.Cloud.CloudBuild.V2.dll\n\nConstructors\n------------\n\n### ServiceName(string, string, string, string)\n\n public ServiceName(string projectId, string locationId, string namespaceId, string serviceId)\n\nConstructs a new instance of a [ServiceName](/dotnet/docs/reference/Google.Cloud.CloudBuild.V2/latest/Google.Cloud.CloudBuild.V2.ServiceName) class from the component parts of pattern\n`projects/{project}/locations/{location}/namespaces/{namespace}/services/{service}`\n\nProperties\n----------\n\n### IsKnownPattern\n\n public bool IsKnownPattern { get; }\n\nWhether this instance contains a resource name with a known pattern.\n\n### LocationId\n\n public string LocationId { get; }\n\nThe `Location` ID. Will not be `null`, unless this instance contains an unparsed resource name.\n\n### NamespaceId\n\n public string NamespaceId { get; }\n\nThe `Namespace` ID. Will not be `null`, unless this instance contains an unparsed resource name.\n\n### ProjectId\n\n public string ProjectId { get; }\n\nThe `Project` ID. Will not be `null`, unless this instance contains an unparsed resource name.\n\n### ServiceId\n\n public string ServiceId { get; }\n\nThe `Service` ID. Will not be `null`, unless this instance contains an unparsed resource name.\n\n### Type\n\n public ServiceName.ResourceNameType Type { get; }\n\nThe [ServiceName.ResourceNameType](/dotnet/docs/reference/Google.Cloud.CloudBuild.V2/latest/Google.Cloud.CloudBuild.V2.ServiceName.ResourceNameType) of the contained resource name.\n\n### UnparsedResource\n\n public UnparsedResourceName UnparsedResource { get; }\n\nThe contained [UnparsedResourceName](https://github.com/googleapis/gax-dotnet/blob/83f42b5edc4529818dbdb34d9ea9ecc3c04f7b6e/Google.Api.Gax/UnparsedResourceName.cs). Only non-`null` if this instance contains an\nunparsed resource name.\n\nMethods\n-------\n\n### Format(string, string, string, string)\n\n public static string Format(string projectId, string locationId, string namespaceId, string serviceId)\n\nFormats the IDs into the string representation of this [ServiceName](/dotnet/docs/reference/Google.Cloud.CloudBuild.V2/latest/Google.Cloud.CloudBuild.V2.ServiceName) with pattern\n`projects/{project}/locations/{location}/namespaces/{namespace}/services/{service}`.\n\n### FormatProjectLocationNamespaceService(string, string, string, string)\n\n public static string FormatProjectLocationNamespaceService(string projectId, string locationId, string namespaceId, string serviceId)\n\nFormats the IDs into the string representation of this [ServiceName](/dotnet/docs/reference/Google.Cloud.CloudBuild.V2/latest/Google.Cloud.CloudBuild.V2.ServiceName) with pattern\n`projects/{project}/locations/{location}/namespaces/{namespace}/services/{service}`.\n\n### FromProjectLocationNamespaceService(string, string, string, string)\n\n public static ServiceName FromProjectLocationNamespaceService(string projectId, string locationId, string namespaceId, string serviceId)\n\nCreates a [ServiceName](/dotnet/docs/reference/Google.Cloud.CloudBuild.V2/latest/Google.Cloud.CloudBuild.V2.ServiceName) with the pattern\n`projects/{project}/locations/{location}/namespaces/{namespace}/services/{service}`.\n\n### FromUnparsed(UnparsedResourceName)\n\n public static ServiceName FromUnparsed(UnparsedResourceName unparsedResourceName)\n\nCreates a [ServiceName](/dotnet/docs/reference/Google.Cloud.CloudBuild.V2/latest/Google.Cloud.CloudBuild.V2.ServiceName) containing an unparsed resource name.\n\n### GetHashCode()\n\n public override int GetHashCode()\n\nReturns a hash code for this resource name.\n\n**Overrides** \n[object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode)\n\n### Parse(string)\n\n public static ServiceName Parse(string serviceName)\n\nParses the given resource name string into a new [ServiceName](/dotnet/docs/reference/Google.Cloud.CloudBuild.V2/latest/Google.Cloud.CloudBuild.V2.ServiceName) instance.\n\n**Remarks** \nTo parse successfully, the resource name must be formatted as one of the following:\n\n- `projects/{project}/locations/{location}/namespaces/{namespace}/services/{service}`\n\n\u003cbr /\u003e\n\n### Parse(string, bool)\n\n public static ServiceName Parse(string serviceName, bool allowUnparsed)\n\nParses the given resource name string into a new [ServiceName](/dotnet/docs/reference/Google.Cloud.CloudBuild.V2/latest/Google.Cloud.CloudBuild.V2.ServiceName) instance; optionally allowing an\nunparseable resource name.\n\n**Remarks** \nTo parse successfully, the resource name must be formatted as one of the following:\n\n- `projects/{project}/locations/{location}/namespaces/{namespace}/services/{service}`\n\nOr may be in any format if `allowUnparsed` is `true`.\n\n\u003cbr /\u003e\n\n### ToString()\n\n public override string ToString()\n\nThe string representation of the resource name.\n\n**Overrides** \n[object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)\n\n### TryParse(string, out ServiceName)\n\n public static bool TryParse(string serviceName, out ServiceName result)\n\nTries to parse the given resource name string into a new [ServiceName](/dotnet/docs/reference/Google.Cloud.CloudBuild.V2/latest/Google.Cloud.CloudBuild.V2.ServiceName) instance.\n\n**Remarks** \nTo parse successfully, the resource name must be formatted as one of the following:\n\n- `projects/{project}/locations/{location}/namespaces/{namespace}/services/{service}`\n\n\u003cbr /\u003e\n\n### TryParse(string, bool, out ServiceName)\n\n public static bool TryParse(string serviceName, bool allowUnparsed, out ServiceName result)\n\nTries to parse the given resource name string into a new [ServiceName](/dotnet/docs/reference/Google.Cloud.CloudBuild.V2/latest/Google.Cloud.CloudBuild.V2.ServiceName) instance; optionally\nallowing an unparseable resource name.\n\n**Remarks** \nTo parse successfully, the resource name must be formatted as one of the following:\n\n- `projects/{project}/locations/{location}/namespaces/{namespace}/services/{service}`\n\nOr may be in any format if `allowUnparsed` is `true`.\n\n\u003cbr /\u003e\n\nOperators\n---------\n\n### operator ==(ServiceName, ServiceName)\n\n public static bool operator ==(ServiceName a, ServiceName b)\n\nDetermines whether two specified resource names have the same value.\n\n### operator !=(ServiceName, ServiceName)\n\n public static bool operator !=(ServiceName a, ServiceName b)\n\nDetermines whether two specified resource names have different values."]]