Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


Substring

Retrieves a substring of this string. The substring starts from a specific character index, and has a specified length.
Read time 3 minutesLast updated 6 days ago

Definition

  • Type: Method
  • Namespace: Unity.Collections
  • Assembly: UnityEngine.ManagedKernelModule

Substring<T>(T, int, int)

Retrieves a substring of this string. The substring starts from a specific character index, and has a specified length.
public static T Substring<T>(this ref T str, int startIndex, int length) where T : unmanaged, INativeList<byte>, IUTF8Bytes

Parameters

str

T
A string to get the substring from.

startIndex

Start index of substring.

length

Length of substring.

Returns

Type

Description

TA new string with length equivalent to
length
that begins at
startIndex
.

Substring<T>(T, int)

Retrieves a substring of this string. The substring starts from a specific character index and continues to the end of the string.
public static T Substring<T>(this ref T str, int startIndex) where T : unmanaged, INativeList<byte>, IUTF8Bytes

Parameters

str

T
A string to get the substring from.

startIndex

Start index of substring.

Returns

Type

Description

TA new string that begins at
startIndex
.

Substring(NativeText, int, int, AllocatorHandle)

Retrieves a substring from this string. The substring starts from a specific character index, and has a specified length. Allocates memory to the new substring with the allocator specified.
public static NativeText Substring(this ref NativeText str, int startIndex, int length, AllocatorManager.AllocatorHandle allocator)

Parameters

A NativeText string to get the substring from.

startIndex

Start index of substring.

length

Length of substring.

The AllocatorManager.AllocatorHandle allocator type to use.

Returns

Type

Description

NativeTextA
NativeText
string with a length equivalent to
length
that starts at
startIndex
and an allocator type of
allocator
.

Substring(NativeText, int, AllocatorHandle)

Retrieves a substring of this string. The substring starts from a specific character index and continues to the end of the string. Allocates memory to the new substring with the allocator specified.
public static NativeText Substring(this ref NativeText str, int startIndex, AllocatorManager.AllocatorHandle allocator)

Parameters

A NativeText string to get the substring from.

startIndex

Start index of substring.

The AllocatorManager.AllocatorHandle allocator type to use.

Returns

Type

Description

NativeTextA NativeText string that begins at
startIndex
and has an allocator of type
allocator
.

Substring(NativeText, int, int)

Retrieves a substring of this string. The substring starts from a specific character index, and has a specified length. The new substring has the same allocator as the string.
public static NativeText Substring(this ref NativeText str, int startIndex, int length)

Parameters

A NativeText string to get the substring from.

startIndex

Start index of substring.

length

Length of substring.

Returns

Type

Description

NativeTextA NativeText string that has length equivalent to
length
and begins at
startIndex
.

Substring(NativeText, int)

Retrieves a substring of this string. The substring starts from a specific character index and continues to the end of the string. The new substring has the same allocator as the string.
public static NativeText Substring(this ref NativeText str, int startIndex)

Parameters

A NativeText to get the substring from.

startIndex

Start index of substring.

Returns

Type

Description

NativeTextA NativeText string that begins at
startIndex
.