# TryGetPreview(out string)

> Retrieves the current string value assigned to the port preview for a given port.

## Definition

* **Type:** Method
* **Namespace:** [Unity.GraphToolkit.Editor.GraphVisualization](/engine/6000.7/script-reference/unity/graphtoolkit/editor/graphvisualization.md)
* **Assembly:** UnityEditor

## TryGetPreview(string)

```csharp
public bool TryGetPreview(out string displayValue)
```

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): When this method returns true, contains the string value of the port preview; otherwise, `null`.

### Returns

| Type                                                          | Description                                                                  |
| ------------------------------------------------------------- | ---------------------------------------------------------------------------- |
| [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | true if the port preview value was successfully retrieved; otherwise, false. |

### Remarks

If no port preview is currently set for the given port, this method returns false and `displayValue` is `null`. Call [PortReference.SetPreview](/engine/6000.7/script-reference/unity/graphtoolkit/editor/graphvisualization/portreference/setpreview.md) to assign a display value to a port preview before querying it. Throws ObjectDisposedException when you access this method after you call [Context.Dispose](/engine/6000.7/script-reference/unity/graphtoolkit/editor/graphvisualization/context/dispose.md) on the context.

### Examples

```csharp
if (context.GetPortReference(portID).TryGetPreview(out var displayValue))
    Debug.Log(displayValue);
```
