# LastIndexOf

> Returns the index of the last occurrence of a single Unicode rune within this string.

## Definition

* **Type:** Method
* **Namespace:** [Unity.Collections](/engine/6000.7/script-reference/unity/collections.md)
* **Assembly:** UnityEngine.ManagedKernelModule

## LastIndexOf\<T>(T, Rune)

Returns the index of the last occurrence of a single Unicode rune within this string.

```csharp
public static int LastIndexOf<T>(this ref T fs, Unicode.Rune rune) where T : unmanaged, INativeList<byte>, IUTF8Bytes
```

### Parameters

**** (T): A string to search.**** (\[Rune]\(/engine/6000.7/script-reference/unity/collections/unicode/rune)): A single Unicode.Rune to search for within this string.

### Returns

| Type                                                       | Description                                                                                                     |
| ---------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- |
| [int](https://learn.microsoft.com/dotnet/api/system.int32) | The index of the last occurrence of the byte sequence within this string. Returns -1 if no occurrence is found. |

## LastIndexOf\<T>(T, byte\*, int)

Returns the index of the last occurrence of a byte sequence within this string.

```csharp
public static int LastIndexOf<T>(this ref T fs, byte* bytes, int bytesLen) where T : unmanaged, INativeList<byte>, IUTF8Bytes
```

### Parameters

**** (T): A string to search.**** (\[byte\*]\(https\://learn.microsoft.com/dotnet/api/system.byte)): A byte sequence to search for within this string.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The number of bytes in the byte sequence.

### Returns

| Type                                                       | Description                                                                                                     |
| ---------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- |
| [int](https://learn.microsoft.com/dotnet/api/system.int32) | The index of the last occurrence of the byte sequence within this string. Returns -1 if no occurrence is found. |

## LastIndexOf\<T>(T, byte\*, int, int, int)

Returns the index of the last occurrence of a byte sequence within a subrange of this string.

```csharp
public static int LastIndexOf<T>(this ref T fs, byte* bytes, int bytesLen, int startIndex, int distance = 2147483647) where T : unmanaged, INativeList<byte>, IUTF8Bytes
```

### Parameters

**** (T): A string to search.**** (\[byte\*]\(https\://learn.microsoft.com/dotnet/api/system.byte)): A byte sequence to search for within this string.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The number of bytes in the byte sequence.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The smallest index in this string to consider as the first byte of the byte sequence.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The greatest index in this string to consider as the first byte of the byte sequence.

### Returns

| Type                                                       | Description                                                                                                   |
| ---------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------- |
| [int](https://learn.microsoft.com/dotnet/api/system.int32) | The index of the last occurrence of the byte sequence within this string. Returns -1 if no occurrences found. |

## LastIndexOf\<T, U>(T, T)

Returns the index of the last occurrence of a substring within this string.

```csharp
public static int LastIndexOf<T, T2>(this ref T fs, in T2 other) where T : unmanaged, INativeList<byte>, IUTF8Bytes where T2 : unmanaged, INativeList<byte>, IUTF8Bytes
```

### Parameters

**** (T): A string to search.**** (T): A substring to search for in the this string.

### Returns

| Type                                                       | Description                                                                                                 |
| ---------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- |
| [int](https://learn.microsoft.com/dotnet/api/system.int32) | The index of the last occurrence of the substring within this string. Returns -1 if no occurrence is found. |

## LastIndexOf\<T, U>(T, T, int, int)

Returns the index of the last occurrence of a substring within a subrange of this string.

```csharp
public static int LastIndexOf<T, T2>(this ref T fs, in T2 other, int startIndex, int distance = 2147483647) where T : unmanaged, INativeList<byte>, IUTF8Bytes where T2 : unmanaged, INativeList<byte>, IUTF8Bytes
```

### Parameters

**** (T): A string to search.**** (T): A substring to search for within this string.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The greatest index in this string to consider as an occurrence of the substring.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The smallest index in this string to consider as an occurrence of the substring.

### Returns

| Type                                                       | Description                                                                                                      |
| ---------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- |
| [int](https://learn.microsoft.com/dotnet/api/system.int32) | the index of the last occurrence of the substring within the first string. Returns -1 if no occurrence is found. |
