StructDeclaration
CSharp struct declaration.
import { StructDeclaration } from "@alloy-js/csharp";
<StructDeclaration attributes={AttributesProp} doc={core.Children} file interfaceTypes={core.Children[]} internal name="string" new partial private protected public readonly ref refkey={core.Refkey} typeParameters={(TypeParameterProps | string)[]} />
import { StructDeclaration } from "@alloy-js/csharp/stc";
StructDeclaration({ attributes: AttributesProp, doc: core.Children, file: boolean, interfaceTypes: core.Children[], internal: boolean, name: string, new: boolean, partial: boolean, private: boolean, protected: boolean, public: boolean, readonly: boolean, ref: boolean, refkey: core.Refkey, typeParameters: (TypeParameterProps | string)[],}).children(children)
attributes | optionalAttributesProp Define attributes to attach |
doc | optionalChildren Doc comment |
file | optionalboolean |
interfaceTypes | optionalChildren[] Interfaces this struct implements |
internal | optionalboolean |
name | string |
new | optionalboolean |
partial | optionalboolean |
private | optionalboolean |
protected | optionalboolean |
public | optionalboolean |
readonly | optionalboolean |
ref | optionalboolean |
refkey | optionalRefkey |
typeParameters | optional(TypeParameterProps | string)[] Type parameters for the struct |
Example
Section titled “Example”<StructDeclaration public name="IMyStruct"> <StructMember public name="MyProperty" type="int" /> <StructMethod public name="MyMethod" returnType="void"> <Parameter name="value" type="int" /> </StructMethod></StructDeclaration>
This will produce:
public struct MyIface{ public int MyProperty { get; set; } public void MyMethod(int value);}