> For the complete documentation index, see [llms.txt](https://docs.yarnspinner.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.yarnspinner.dev/2.1/api/csharp/yarn.compiler/yarn.compiler.declaration/yarn.compiler.declaration.createvariable.md).

# CreateVariable(string,Yarn.IType,IConvertible,string)

Method in [Declaration](/2.1/api/csharp/yarn.compiler/yarn.compiler.declaration.md)

## Summary

Creates a new instance of the [Declaration](/2.1/api/csharp/yarn.compiler/yarn.compiler.declaration.md) class, using the given `name` and default value. The `ReturnType` of the new instance will be configured based on the type of `defaultValue` , and the `DeclarationType` will be `Type.Variable` . All other properties will be their default values.

```csharp
public static Declaration CreateVariable(string name, Yarn.IType type, IConvertible defaultValue, string description = null)
```

## Parameters

| Name                                                  | Description                                                                                                          |
| ----------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- |
| `string` name                                         | The name of the new declaration.                                                                                     |
| `System.IConvertible` defaultValue                    | The default value of the declaration. This must be a string, a number (integer or floating-point), or boolean value. |
| `string` description                                  | The description of the new declaration.                                                                              |
| [Yarn.IType](/2.1/api/csharp/yarn/yarn.itype.md) type |                                                                                                                      |

## Returns

A new instance of the [Declaration](/2.1/api/csharp/yarn.compiler/yarn.compiler.declaration.md) class.
