# Keys

> USearch for C#

Keys are 128 bits wide and render as lowercase dashed UUIDs, with integer identities parked in the low eight bytes, so `42UL` converts implicitly and `TryGetUInt64` reads one back.
A full identity comes from `Key.Parse("0123abcd-4567-89ef-fedc-ba9876543210")`, or `Key.TryParse` when the text may be malformed.
Parsing reads the dashes as separators rather than positions, so they may sit anywhere or nowhere, and what they leave behind must be thirty-two hexadecimal digits of either case.
`Key.FromGuid` and `Key.ToGuid` carry an identity across to `System.Guid`, which is where a time-ordered `Guid.CreateVersion7()` key comes from.

`using Cloud.Unum.USearch;`

## Key

A 128-bit entry identity, most significant byte first, rendered as a lowercase dashed UUID.

```csharp
struct Key
```

Mirrors `usearch_key_t`.

Keys need not be unique: several entries may share one, and DenseIndex.Count reports how many. Integer identities park in the low eight bytes, so the key 42 prints as `00000000-0000-0000-0000-00000000002a`.

The sixteen bytes are held in the order the ABI fixes rather than in a Guid field, whose first three groups sit little-endian in memory and would cross the boundary byte-swapped. The UUID vocabulary is reached through ToGuid and FromGuid instead, and it is what renders and parses a key.

## ByteCount

The number of identity bytes a key carries.

```csharp
const int ByteCount;
```

## FromUInt64

Parks an integer identity in the low eight bytes, zeroing the rest.

```csharp
Key FromUInt64(ulong value);
```

- `value`: The integer identity.

## operator Key

Parks an integer identity in the low eight bytes, zeroing the rest.

```csharp
implicit operator Key(ulong value);
```

- `value`: The integer identity.

## FromGuid

Reads a UUID's canonical byte order as an identity.

```csharp
Key FromGuid(Guid identity);
```

- `identity`: The UUID.

## Parse

Reads the rendering ToString produces; dashes may sit anywhere.

```csharp
Key Parse(string text);
```

- `text`: The thirty-two hexadecimal digits, dashed or not.

## TryParse

Reads the rendering ToString produces, without throwing.

```csharp
bool TryParse(string? text, out Key key);
```

The dashes are separators rather than positions, so they may sit anywhere or nowhere. What they leave behind must be thirty-two hexadecimal digits, of either case.

- `text`: The thirty-two hexadecimal digits, dashed or not.
- `key`: The key those digits spell, or the nil key when they do not.

## *

Compares two keys byte by byte.

```csharp
bool operator==(Key left, Key right);
```

- `operator==`
- `operator!=`

- `left`: The first key.
- `right`: The second key.

## TryGetUInt64

Reads the integer identity in the low eight bytes.

```csharp
bool TryGetUInt64(out ulong value);
```

- `value`: The identity, when the high eight bytes carry nothing.

## ToGuid

Reads the identity as a UUID, whose canonical byte order is the ABI's.

```csharp
Guid ToGuid();
```

## ToString

Renders the key as a lowercase dashed UUID.

```csharp
override string ToString();
```

## Equals

Compares two keys byte by byte.

```csharp
bool Equals(Key other);
```

```csharp
override bool Equals(object? other);
```

Compares this key against any object.

- `other`: The key to compare against.

## GetHashCode

Hashes the sixteen identity bytes.

```csharp
override int GetHashCode();
```

