# StreamId Methods

[Type overview](/orleans/docs/api/csharp/microsoft.orleans.streaming/orleans.runtime.streamid/)

## CompareTo(StreamId) {#compareto-orleans-runtime-streamid-3568ef20}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.streaming/orleans.runtime.streamid/methods/compareto-orleans-runtime-streamid-3568ef20/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Streaming/StreamId.cs#L144)

```csharp
public int CompareTo(StreamId other)
```

Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.

### Parameters

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

### Returns

A value that indicates the relative order of the objects being compared. The return value has these meanings: 

| Value | Meaning |
| --- | --- |
| Less than zero | This instance precedes `other` in the sort order. |
| Zero | This instance occurs in the same position in the sort order as `other`. |
| Greater than zero | This instance follows `other` in the sort order. |

## Create(IStreamIdentity) {#create-orleans-streams-istreamidentity-7b4d0026}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.streaming/orleans.runtime.streamid/methods/create-orleans-streams-istreamidentity-7b4d0026/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Streaming/StreamId.cs#L141)

```csharp
public static StreamId Create(IStreamIdentity streamIdentity)
```

Initializes a new instance of the [StreamId](/orleans/docs/api/csharp/microsoft.orleans.streaming/orleans.runtime.streamid/) struct.

### Parameters

- `streamIdentity` (`IStreamIdentity`): The stream identity.

## Create(ReadOnlySpan&lt;byte&gt;, ReadOnlySpan&lt;byte&gt;) {#create-system-readonlyspan-byte-system-readonlyspan-byte-ded9f2ed}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.streaming/orleans.runtime.streamid/methods/create-system-readonlyspan-byte-system-readonlyspan-byte-ded9f2ed/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Streaming/StreamId.cs)

```csharp
public static StreamId Create(ReadOnlySpan<byte> ns, ReadOnlySpan<byte> key)
```

Initializes a new instance of the [StreamId](/orleans/docs/api/csharp/microsoft.orleans.streaming/orleans.runtime.streamid/) struct.

### Parameters

- `ns` (`ReadOnlySpan<byte>`): The namespace.
- `key` (`ReadOnlySpan<byte>`): The key.

## Create(string, Guid) {#create-string-system-guid-39c47a07}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.streaming/orleans.runtime.streamid/methods/create-string-system-guid-39c47a07/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Streaming/StreamId.cs)

```csharp
public static StreamId Create(string ns, Guid key)
```

Initializes a new instance of the [StreamId](/orleans/docs/api/csharp/microsoft.orleans.streaming/orleans.runtime.streamid/) struct.

### Parameters

- `ns` (`string`): The namespace.
- `key` (`Guid`): The key.

## Create(string, long) {#create-string-long-0d3b61c2}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.streaming/orleans.runtime.streamid/methods/create-string-long-0d3b61c2/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Streaming/StreamId.cs)

```csharp
public static StreamId Create(string ns, long key)
```

Initializes a new instance of the [StreamId](/orleans/docs/api/csharp/microsoft.orleans.streaming/orleans.runtime.streamid/) struct.

### Parameters

- `ns` (`string`): The namespace.
- `key` (`long`): The key.

## Create(string, string) {#create-string-string-a59c031f}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.streaming/orleans.runtime.streamid/methods/create-string-string-a59c031f/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Streaming/StreamId.cs)

```csharp
public static StreamId Create(string ns, string key)
```

Initializes a new instance of the [StreamId](/orleans/docs/api/csharp/microsoft.orleans.streaming/orleans.runtime.streamid/) struct.

### Parameters

- `ns` (`string`): The namespace.
- `key` (`string`): The key.

## Equals(StreamId) {#equals-orleans-runtime-streamid-43653556}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.streaming/orleans.runtime.streamid/methods/equals-orleans-runtime-streamid-43653556/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Streaming/StreamId.cs#L147)

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

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

### Parameters

- `other` (`StreamId`): 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-24080214}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.streaming/orleans.runtime.streamid/methods/equals-object-nullable-24080214/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Streaming/StreamId.cs#L150)

```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-64c914e6}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.streaming/orleans.runtime.streamid/methods/gethashcode-64c914e6/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Streaming/StreamId.cs#L221)

```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.

## GetKeyAsString {#getkeyasstring-89b94235}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.streaming/orleans.runtime.streamid/methods/getkeyasstring-89b94235/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Streaming/StreamId.cs#L231)

```csharp
public string GetKeyAsString()
```

Returns the [StreamId](/orleans/docs/api/csharp/microsoft.orleans.streaming/orleans.runtime.streamid/) component of this instance as a string.

### Returns

The key component of this instance.

## GetNamespace {#getnamespace-042193ef}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.streaming/orleans.runtime.streamid/methods/getnamespace-042193ef/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Streaming/StreamId.cs#L237)

```csharp
public string? GetNamespace()
```

Returns the [StreamId](/orleans/docs/api/csharp/microsoft.orleans.streaming/orleans.runtime.streamid/) component of this instance as a string.

### Returns

The namespace component of this instance.

## GetObjectData(SerializationInfo, StreamingContext) {#getobjectdata-system-runtime-serialization-serializationinfo-system-runtime-seri-bd959eb5}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.streaming/orleans.runtime.streamid/methods/getobjectdata-system-runtime-serialization-serializationinfo-system-runtime-seri-bd959eb5/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Streaming/StreamId.cs#L171-L174)

```csharp
public void GetObjectData(SerializationInfo info, StreamingContext context)
```

Populates a `System.Runtime.Serialization.SerializationInfo` with the data needed to serialize the target object.

### Parameters

- `info` (`SerializationInfo`): The `System.Runtime.Serialization.SerializationInfo` to populate with data.
- `context` (`StreamingContext`): The destination (see `System.Runtime.Serialization.StreamingContext`) for this serialization.

### Exceptions

- `System.Security.SecurityException`: The caller does not have the required permission.

## Parse(ReadOnlySpan&lt;byte&gt;) {#parse-system-readonlyspan-byte-bdb7e483}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.streaming/orleans.runtime.streamid/methods/parse-system-readonlyspan-byte-bdb7e483/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Streaming/StreamId.cs#L211-L217)

```csharp
public static StreamId Parse(ReadOnlySpan<byte> value)
```

Parses a [StreamId](/orleans/docs/api/csharp/microsoft.orleans.streaming/orleans.runtime.streamid/) instance from a `System.String`.

### Parameters

- `value` (`ReadOnlySpan<byte>`): The UTF-8 encoded value.

### Returns

The parsed stream identity.

## ToString {#tostring-c3c2a2c7}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.streaming/orleans.runtime.streamid/methods/tostring-c3c2a2c7/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Streaming/StreamId.cs#L177)

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

Returns the fully qualified type name of this instance.

### Returns

The fully qualified type name.

## operator ==(StreamId, StreamId) {#op-equality-orleans-runtime-streamid-orleans-runtime-streamid-f2ddaa09}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.streaming/orleans.runtime.streamid/methods/op-equality-orleans-runtime-streamid-orleans-runtime-streamid-f2ddaa09/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Streaming/StreamId.cs#L158)

```csharp
public static bool operator ==(StreamId s1, StreamId s2)
```

Compares two [StreamId](/orleans/docs/api/csharp/microsoft.orleans.streaming/orleans.runtime.streamid/) instances for equality.

### Parameters

- `s1` (`StreamId`): The first stream identity.
- `s2` (`StreamId`): The second stream identity.

### Returns

The result of the operator.

## operator !=(StreamId, StreamId) {#op-inequality-orleans-runtime-streamid-orleans-runtime-streamid-50444c4d}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.streaming/orleans.runtime.streamid/methods/op-inequality-orleans-runtime-streamid-orleans-runtime-streamid-50444c4d/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Orleans.Streaming/StreamId.cs#L166)

```csharp
public static bool operator !=(StreamId s1, StreamId s2)
```

Compares two [StreamId](/orleans/docs/api/csharp/microsoft.orleans.streaming/orleans.runtime.streamid/) instances for equality.

### Parameters

- `s1` (`StreamId`): The first stream identity.
- `s2` (`StreamId`): The second stream identity.

### Returns

The result of the operator.
