# StringView

> Structure that holds a view on a string, with a specified range of [startIndex, endIndex[.

## Definition

* **Type:** Struct
* **Namespace:** [UnityEditor.Search](/engine/6000.6/script-reference/unityeditor/search.md)
* **Assembly:** UnityEditor
* **Implements:** [IEnumerable\<char>](https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1), [IEnumerable](https://learn.microsoft.com/dotnet/api/system.collections.ienumerable), [IEquatable\<StringView>](https://learn.microsoft.com/dotnet/api/system.iequatable-1)

```csharp
public readonly struct StringView : IEnumerable<char>, IEnumerable, IEquatable<StringView>
```

## Remarks

A [StringView](/engine/6000.6/script-reference/unityeditor/search/stringview.md) contains only a reference to the original string, a start and an end index. It can be used to quickly create substrings or do any other operations that would return a contiguous subset of the original string, without actually copying the data.

## Static Fields

| Value                                                                           | Description                                                                              |
| ------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- |
| [empty](/engine/6000.6/script-reference/unityeditor/search/stringview/empty.md) | An empty [StringView](/engine/6000.6/script-reference/unityeditor/search/stringview.md). |
| [nil](/engine/6000.6/script-reference/unityeditor/search/stringview/nil.md)     | A null [StringView](/engine/6000.6/script-reference/unityeditor/search/stringview.md).   |

## Constructors

| Constructor                                                                                                                                               | Description                                                                                                                                                                                       |
| --------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [StringView(System.String)](/engine/6000.6/script-reference/unityeditor/search/stringview/ctor.md#stringview\(string\))                                   | Constructs a [StringView](/engine/6000.6/script-reference/unityeditor/search/stringview.md) over an entire string.                                                                                |
| [StringView(System.String,System.Int32)](/engine/6000.6/script-reference/unityeditor/search/stringview/ctor.md#stringview\(string-int\))                  | Constructs a [StringView](/engine/6000.6/script-reference/unityeditor/search/stringview.md) from a string, starting at index **startIndex**.                                                      |
| [StringView(System.String,System.Int32,System.Int32)](/engine/6000.6/script-reference/unityeditor/search/stringview/ctor.md#stringview\(string-int-int\)) | Constructs a [StringView](/engine/6000.6/script-reference/unityeditor/search/stringview.md) from a string, starting at index **startIndex** and ending at, but not including, index **endIndex**. |

## Properties

| Property                                                                                  | Description                                                                                                                               |
| ----------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
| [baseString](/engine/6000.6/script-reference/unityeditor/search/stringview/basestring.md) | The base string which this [StringView](/engine/6000.6/script-reference/unityeditor/search/stringview.md) references.                     |
| [endIndex](/engine/6000.6/script-reference/unityeditor/search/stringview/endindex.md)     | The end index.                                                                                                                            |
| [this\[\]](/engine/6000.6/script-reference/unityeditor/search/stringview/item.md)         | Gets the character at a specified position in the current [StringView](/engine/6000.6/script-reference/unityeditor/search/stringview.md). |
| [length](/engine/6000.6/script-reference/unityeditor/search/stringview/length.md)         | The length of this [StringView](/engine/6000.6/script-reference/unityeditor/search/stringview.md).                                        |
| [startIndex](/engine/6000.6/script-reference/unityeditor/search/stringview/startindex.md) | The start index.                                                                                                                          |
| [valid](/engine/6000.6/script-reference/unityeditor/search/stringview/valid.md)           | Boolean indicating if the [StringView](/engine/6000.6/script-reference/unityeditor/search/stringview.md) is valid.                        |

## Methods

| Method                                                                                          | Description                                                                                                                                                                                                                                                                              |
| ----------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [Contains](/engine/6000.6/script-reference/unityeditor/search/stringview/contains.md)           | Checks if a character is contained in the [StringView](/engine/6000.6/script-reference/unityeditor/search/stringview.md).                                                                                                                                                                |
| [EndsWith](/engine/6000.6/script-reference/unityeditor/search/stringview/endswith.md)           | Checks if the [StringView](/engine/6000.6/script-reference/unityeditor/search/stringview.md) ends with the character **c**.                                                                                                                                                              |
| [Equals](/engine/6000.6/script-reference/unityeditor/search/stringview/equals.md)               | Checks if the [StringView](/engine/6000.6/script-reference/unityeditor/search/stringview.md) is equal to the object.                                                                                                                                                                     |
| [GetEnumerator](/engine/6000.6/script-reference/unityeditor/search/stringview/getenumerator.md) | Gets a character enumerator over this [StringView](/engine/6000.6/script-reference/unityeditor/search/stringview.md).                                                                                                                                                                    |
| [GetHashCode](/engine/6000.6/script-reference/unityeditor/search/stringview/gethashcode.md)     | Gets the hashcode of this [StringView](/engine/6000.6/script-reference/unityeditor/search/stringview.md).                                                                                                                                                                                |
| [IndexOf](/engine/6000.6/script-reference/unityeditor/search/stringview/indexof.md)             | Returns the index of the first occurence of another [StringView](/engine/6000.6/script-reference/unityeditor/search/stringview.md) within this one.                                                                                                                                      |
| [LastIndexOf](/engine/6000.6/script-reference/unityeditor/search/stringview/lastindexof.md)     | Returns the index of the last occurence of another [StringView](/engine/6000.6/script-reference/unityeditor/search/stringview.md) within this one.                                                                                                                                       |
| [StartsWith](/engine/6000.6/script-reference/unityeditor/search/stringview/startswith.md)       | Checks if the [StringView](/engine/6000.6/script-reference/unityeditor/search/stringview.md) starts with the character **c**.                                                                                                                                                            |
| [Substring](/engine/6000.6/script-reference/unityeditor/search/stringview/substring.md)         | Returns a substring of the current [StringView](/engine/6000.6/script-reference/unityeditor/search/stringview.md), starting at index **start** and until the end of the [StringView](/engine/6000.6/script-reference/unityeditor/search/stringview.md).                                  |
| [ToString](/engine/6000.6/script-reference/unityeditor/search/stringview/tostring.md)           | Converts the current [StringView](/engine/6000.6/script-reference/unityeditor/search/stringview.md) into a string.                                                                                                                                                                       |
| [Trim](/engine/6000.6/script-reference/unityeditor/search/stringview/trim.md)                   | Returns a new [StringView](/engine/6000.6/script-reference/unityeditor/search/stringview.md) in which all leading and trailing occurrences of a set of specified characters from the current [StringView](/engine/6000.6/script-reference/unityeditor/search/stringview.md) are removed. |

## Operators

| Operator                                                                                      | Description              |
| --------------------------------------------------------------------------------------------- | ------------------------ |
| [operator ==](/engine/6000.6/script-reference/unityeditor/search/stringview/op-equality.md)   | The equals operator.     |
| [operator !=](/engine/6000.6/script-reference/unityeditor/search/stringview/op-inequality.md) | The not equals operator. |
