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>
childrenoptional ChildrenVariable value
constoptional booleanConstant variable. Add the const modifier.
namestring | NamekeyVariable name
refkeyoptional RefkeyVariable refkey
typeoptional ChildrenType of the variable declaration. If not specified, defaults to “var”
usingoptional booleanDisposable 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;