Skip to content

VarDeclaration

Render a variable declaration

Props for VarDeclaration component

import { VarDeclaration } from "@alloy-js/csharp";
<VarDeclaration
const
name={string | Namekey}
refkey={Refkey}
type={Children}
using
>
{children}
</VarDeclaration>
childrenoptionalChildren

Variable value

constoptionalboolean

Constant variable. Add the const modifier.

namestring | Namekey

Variable name

refkeyoptionalRefkey

Variable refkey

typeoptionalChildren

Type of the variable declaration. If not specified, defaults to “var”

usingoptionalboolean

Disposable variable. Add the using modifier.

with var

<VarDeclaration name="myVar">42</VarDeclaration>

This will render:

var myVar = 42;

with type

<VarDeclaration name="myVar" type="int">42</VarDeclaration>

This will render:

int myVar = 42;