# MessageId Methods

[Type overview](/orleans/docs/api/csharp/microsoft.orleans.durable/orleans.durable.messaging.messageid/)

## Create(ReadOnlySpan&lt;string&gt;) {#create-params-system-readonlyspan-string-ac1e0b24}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable/orleans.durable.messaging.messageid/methods/create-params-system-readonlyspan-string-ac1e0b24/)

[Source](https://github.com/dotnet/orleans/blob/6a0e937f544c35ffcf11b37e4c2b7de5a1580a03/src/Orleans.Durable/Messaging/MessageId.cs#L34)

```csharp
public static MessageId Create(params ReadOnlySpan<string> segments)
```

Creates a message identity from literal segments in root-first order.

### Parameters

- `segments` (`ReadOnlySpan<string>`): The nonempty literal segments.

### Returns

The message identity.

### Exceptions

- `System.ArgumentNullException`: A segment is null.
- `System.ArgumentException`: The input or a segment is empty, or a segment contains an unpaired surrogate.

## Equals(MessageId) {#equals-orleans-durable-messaging-messageid-e9f01ac8}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable/orleans.durable.messaging.messageid/methods/equals-orleans-durable-messaging-messageid-e9f01ac8/)

[Source](https://github.com/dotnet/orleans/blob/6a0e937f544c35ffcf11b37e4c2b7de5a1580a03/src/Orleans.Durable/Messaging/MessageId.cs#L59)

```csharp
public bool Equals(MessageId other)
```

Indicates whether the current object is equal to another object of the same type.

### Parameters

- `other` (`MessageId`): An object to compare with this object.

### Returns

`true` if the current object is equal to the `other` parameter; otherwise, `false`.

## Equals(object?) {#equals-object-nullable-51703403}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable/orleans.durable.messaging.messageid/methods/equals-object-nullable-51703403/)

[Source](https://github.com/dotnet/orleans/blob/6a0e937f544c35ffcf11b37e4c2b7de5a1580a03/src/Orleans.Durable/Messaging/MessageId.cs#L62)

```csharp
public override bool Equals(object? obj)
```

Indicates whether this instance and a specified object are equal.

### Parameters

- `obj` (`object?`): The object to compare with the current instance.

### Returns

`true` if `obj` and this instance are the same type and represent the same value; otherwise, `false`.

## GetHashCode {#gethashcode-31c372ab}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable/orleans.durable.messaging.messageid/methods/gethashcode-31c372ab/)

[Source](https://github.com/dotnet/orleans/blob/6a0e937f544c35ffcf11b37e4c2b7de5a1580a03/src/Orleans.Durable/Messaging/MessageId.cs#L65)

```csharp
public override int GetHashCode()
```

Returns the hash code for this instance.

### Returns

A 32-bit signed integer that is the hash code for this instance.

## Parse(ReadOnlySpan&lt;char&gt;, IFormatProvider?) {#parse-system-readonlyspan-char-system-iformatprovider-nullable-e064fc24}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable/orleans.durable.messaging.messageid/methods/parse-system-readonlyspan-char-system-iformatprovider-nullable-e064fc24/)

[Source](https://github.com/dotnet/orleans/blob/6a0e937f544c35ffcf11b37e4c2b7de5a1580a03/src/Orleans.Durable/Messaging/MessageId.cs)

```csharp
public static MessageId Parse(ReadOnlySpan<char> s, IFormatProvider? provider = null)
```

Parses a span of characters into a value.

### Parameters

- `s` (`ReadOnlySpan<char>`): The span of characters to parse.
- `provider` (`IFormatProvider?`): An object that provides culture-specific formatting information about `s`.

### Returns

The result of parsing `s`.

### Exceptions

- `System.FormatException`: `s` is not in the correct format.
- `System.OverflowException`: `s` is not representable by `TSelf`.

## Parse(string, IFormatProvider?) {#parse-string-system-iformatprovider-nullable-4ca1c70f}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable/orleans.durable.messaging.messageid/methods/parse-string-system-iformatprovider-nullable-4ca1c70f/)

[Source](https://github.com/dotnet/orleans/blob/6a0e937f544c35ffcf11b37e4c2b7de5a1580a03/src/Orleans.Durable/Messaging/MessageId.cs)

```csharp
public static MessageId Parse(string s, IFormatProvider? provider = null)
```

Parses a string into a value.

### Parameters

- `s` (`string`): The string to parse.
- `provider` (`IFormatProvider?`): An object that provides culture-specific formatting information about `s`.

### Returns

The result of parsing `s`.

### Exceptions

- `System.ArgumentNullException`: `s` is `null`.
- `System.FormatException`: `s` is not in the correct format.
- `System.OverflowException`: `s` is not representable by `TSelf`.

## ToString {#tostring-b22355e4}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable/orleans.durable.messaging.messageid/methods/tostring-b22355e4/)

[Source](https://github.com/dotnet/orleans/blob/6a0e937f544c35ffcf11b37e4c2b7de5a1580a03/src/Orleans.Durable/Messaging/MessageId.cs#L80)

```csharp
public override string ToString()
```

Returns the fully qualified type name of this instance.

### Returns

The fully qualified type name.

## ToString(string?, IFormatProvider?) {#tostring-string-nullable-system-iformatprovider-nullable-5ee89dd3}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable/orleans.durable.messaging.messageid/methods/tostring-string-nullable-system-iformatprovider-nullable-5ee89dd3/)

[Source](https://github.com/dotnet/orleans/blob/6a0e937f544c35ffcf11b37e4c2b7de5a1580a03/src/Orleans.Durable/Messaging/MessageId.cs#L83)

```csharp
public string ToString(string? format, IFormatProvider? formatProvider)
```

Formats the value of the current instance using the specified format.

### Parameters

- `format` (`string?`): The format to use. -or- A null reference (`Nothing` in Visual Basic) to use the default format defined for the type of the `System.IFormattable` implementation.
- `formatProvider` (`IFormatProvider?`): The provider to use to format the value. -or- A null reference (`Nothing` in Visual Basic) to obtain the numeric format information from the current locale setting of the operating system.

### Returns

The value of the current instance in the specified format.

## TryFormat(Span&lt;char&gt;, int, ReadOnlySpan&lt;char&gt;, IFormatProvider?) {#tryformat-system-span-char-out-int-system-readonlyspan-char-system-iformatprovid-e10b5778}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable/orleans.durable.messaging.messageid/methods/tryformat-system-span-char-out-int-system-readonlyspan-char-system-iformatprovid-e10b5778/)

[Source](https://github.com/dotnet/orleans/blob/6a0e937f544c35ffcf11b37e4c2b7de5a1580a03/src/Orleans.Durable/Messaging/MessageId.cs#L87)

```csharp
public bool TryFormat(Span<char> destination, out int charsWritten, ReadOnlySpan<char> format, IFormatProvider? provider)
```

Tries to format the value of the current instance into the provided span of characters.

### Parameters

- `destination` (`Span<char>`): The span in which to write this instance's value formatted as a span of characters.
- `charsWritten` (`int`): When this method returns, contains the number of characters that were written in `destination`.
- `format` (`ReadOnlySpan<char>`): A span containing the characters that represent a standard or custom format string that defines the acceptable format for `destination`.
- `provider` (`IFormatProvider?`): An optional object that supplies culture-specific formatting information for `destination`.

### Returns

`true` if the formatting was successful; otherwise, `false`.

## TryParse(ReadOnlySpan&lt;char&gt;, IFormatProvider?, MessageId) {#tryparse-system-readonlyspan-char-system-iformatprovider-nullable-out-orleans-du-71699b48}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable/orleans.durable.messaging.messageid/methods/tryparse-system-readonlyspan-char-system-iformatprovider-nullable-out-orleans-du-71699b48/)

[Source](https://github.com/dotnet/orleans/blob/6a0e937f544c35ffcf11b37e4c2b7de5a1580a03/src/Orleans.Durable/Messaging/MessageId.cs)

```csharp
public static bool TryParse(ReadOnlySpan<char> s, IFormatProvider? provider, out MessageId result)
```

Tries to parse a span of characters into a value.

### Parameters

- `s` (`ReadOnlySpan<char>`): The span of characters to parse.
- `provider` (`IFormatProvider?`): An object that provides culture-specific formatting information about `s`.
- `result` (`MessageId`): When this method returns, contains the result of successfully parsing `s`, or an undefined value on failure.

### Returns

`true` if `s` was successfully parsed; otherwise, `false`.

## TryParse(string?, IFormatProvider?, MessageId) {#tryparse-string-nullable-system-iformatprovider-nullable-out-orleans-durable-mes-b08514e2}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable/orleans.durable.messaging.messageid/methods/tryparse-string-nullable-system-iformatprovider-nullable-out-orleans-durable-mes-b08514e2/)

[Source](https://github.com/dotnet/orleans/blob/6a0e937f544c35ffcf11b37e4c2b7de5a1580a03/src/Orleans.Durable/Messaging/MessageId.cs)

```csharp
public static bool TryParse(string? s, IFormatProvider? provider, out MessageId result)
```

Tries to parse a string into a value.

### Parameters

- `s` (`string?`): The string to parse.
- `provider` (`IFormatProvider?`): An object that provides culture-specific formatting information about `s`.
- `result` (`MessageId`): When this method returns, contains the result of successfully parsing `s` or an undefined value on failure.

### Returns

`true` if `s` was successfully parsed; otherwise, `false`.

## operator ==(MessageId, MessageId) {#op-equality-orleans-durable-messaging-messageid-orleans-durable-messaging-messag-72b9d0a8}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable/orleans.durable.messaging.messageid/methods/op-equality-orleans-durable-messaging-messageid-orleans-durable-messaging-messag-72b9d0a8/)

[Source](https://github.com/dotnet/orleans/blob/6a0e937f544c35ffcf11b37e4c2b7de5a1580a03/src/Orleans.Durable/Messaging/MessageId.cs#L71)

```csharp
public static bool operator ==(MessageId left, MessageId right)
```

Compares message identities.

### Parameters

- `left` (`MessageId`): The first identity.
- `right` (`MessageId`): The second identity.

### Returns

Whether the identities are equal.

## operator !=(MessageId, MessageId) {#op-inequality-orleans-durable-messaging-messageid-orleans-durable-messaging-mess-86c18e54}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable/orleans.durable.messaging.messageid/methods/op-inequality-orleans-durable-messaging-messageid-orleans-durable-messaging-mess-86c18e54/)

[Source](https://github.com/dotnet/orleans/blob/6a0e937f544c35ffcf11b37e4c2b7de5a1580a03/src/Orleans.Durable/Messaging/MessageId.cs#L77)

```csharp
public static bool operator !=(MessageId left, MessageId right)
```

Compares message identities for inequality.

### Parameters

- `left` (`MessageId`): The first identity.
- `right` (`MessageId`): The second identity.

### Returns

Whether the identities differ.
