# FormatItem(SearchContext, SearchItem, string)

> Take a format string and replace all selectors in it with the selected values obtained from a SearchItem.

## Definition

* **Type:** Method
* **Namespace:** [UnityEditor.Search](/engine/6000.7/script-reference/unityeditor/search.md)
* **Assembly:** UnityEditor

```csharp
public static string FormatItem(SearchContext ctx, SearchItem item, string formatString)
```

### Parameters

**** (\[SearchContext]\(/engine/6000.7/script-reference/unityeditor/search/searchcontext)): SearchContext that yielded the SearchItem.**** (\[SearchItem]\(/engine/6000.7/script-reference/unityeditor/search/searchitem)): SearchItem to select value from.**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): Format string that mayh contain selectors.

### Returns

| Type                                                           | Description                                                                                         |
| -------------------------------------------------------------- | --------------------------------------------------------------------------------------------------- |
| [string](https://learn.microsoft.com/dotnet/api/system.string) | Returns a string where selectors have been replaced by the selected values from a given SearchItem. |

### Examples

```csharp
[Description("Convert arguments to a string allowing you to format the result.")]
[SearchExpressionEvaluator(SearchExpressionType.Selector | SearchExpressionType.Text, SearchExpressionType.Iterable | SearchExpressionType.Literal | SearchExpressionType.Variadic)]
[SearchExpressionEvaluatorSignatureOverload(SearchExpressionType.Iterable | SearchExpressionType.Literal | SearchExpressionType.Variadic)]
public static IEnumerable<SearchItem> FormatItems(SearchExpressionContext c)
{
    var skipCount = 0;
    if (SearchExpression.GetFormatString(c.args[0], out var formatStr))
        skipCount++;
    var items = c.args.Skip(skipCount).SelectMany(e => e.Execute(c));
    var dataSet = SearchExpression.ProcessValues(items, null, item => SearchExpression.FormatItem(c.search, item, formatStr));
    return dataSet;
}
```
