# TrySetValue

> Tries to set the value of a property at the given path to the given value.

## Definition

* **Type:** Method
* **Namespace:** [Unity.Properties](/engine/6000.5/script-reference/unity/properties.md)
* **Assembly:** UnityEngine.PropertiesModule

## TrySetValue\<T, U>(T, string, T)

Tries to set the value of a property at the given path to the given value.

```csharp
public static bool TrySetValue<TContainer, TValue>(TContainer container, string name, TValue value)
```

### Parameters

**** (T): The container whose property will be set.**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): The name of the property to set.**** (T): The value to assign to the property.

### Returns

| Type                                                          | Description                                               |
| ------------------------------------------------------------- | --------------------------------------------------------- |
| [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | `true` if the value was set correctly; `false` otherwise. |

### Remarks

This method is NOT thread safe.

## TrySetValue\<T, U>(T, string, T)

Tries to set the value of a property at the given path to the given value.

```csharp
public static bool TrySetValue<TContainer, TValue>(ref TContainer container, string name, TValue value)
```

### Parameters

**** (T): The container whose property will be set.**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): The name of the property to set.**** (T): The value to assign to the property.

### Returns

| Type                                                          | Description                                               |
| ------------------------------------------------------------- | --------------------------------------------------------- |
| [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | `true` if the value was set correctly; `false` otherwise. |

### Remarks

This method is NOT thread safe.

## TrySetValue\<T, U>(T, PropertyPath, T)

Tries to set the value of a property at the given path to the given value.

```csharp
public static bool TrySetValue<TContainer, TValue>(TContainer container, in PropertyPath path, TValue value)
```

### Parameters

**** (T): The container whose property will be set.**** (\[PropertyPath]\(/engine/6000.5/script-reference/unity/properties/propertypath)): The path of the property to set.**** (T): The value to assign to the property.

### Returns

| Type                                                          | Description                                               |
| ------------------------------------------------------------- | --------------------------------------------------------- |
| [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | `true` if the value was set correctly; `false` otherwise. |

### Remarks

This method is NOT thread safe.

## TrySetValue\<T, U>(T, PropertyPath, T)

Tries to set the value of a property at the given path to the given value.

```csharp
public static bool TrySetValue<TContainer, TValue>(ref TContainer container, in PropertyPath path, TValue value)
```

### Parameters

**** (T): The container whose property will be set.**** (\[PropertyPath]\(/engine/6000.5/script-reference/unity/properties/propertypath)): The path of the property to set.**** (T): The value to assign to the property.

### Returns

| Type                                                          | Description                                               |
| ------------------------------------------------------------- | --------------------------------------------------------- |
| [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | `true` if the value was set correctly; `false` otherwise. |

### Remarks

This method is NOT thread safe.

## TrySetValue\<T, U>(T, PropertyPath, T, VisitReturnCode)

Tries to set the value of a property at the given path to the given value.

```csharp
public static bool TrySetValue<TContainer, TValue>(ref TContainer container, in PropertyPath path, TValue value, out VisitReturnCode returnCode)
```

### Parameters

**** (T): The container whose property will be set.**** (\[PropertyPath]\(/engine/6000.5/script-reference/unity/properties/propertypath)): The path of the property to set.**** (T): The value to assign to the property.**** (\[VisitReturnCode]\(/engine/6000.5/script-reference/unity/properties/visitreturncode)): When this method returns, contains the return code.

### Returns

| Type                                                          | Description                                               |
| ------------------------------------------------------------- | --------------------------------------------------------- |
| [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | `true` if the value was set correctly; `false` otherwise. |

### Remarks

This method is NOT thread safe.
