ClassDeclaration
CSharp class declaration.
import { ClassDeclaration } from "@alloy-js/csharp";
<ClassDeclaration abstract attributes={AttributesProp} baseType={Children} doc={Children} file interfaceTypes={Children[]} internal name="string" partial primaryConstructor={ParameterProps[]} private protected public refkey={Refkey} sealed static typeParameters={(string | TypeParameterProps)[]} />
import { ClassDeclaration } from "@alloy-js/csharp/stc";
ClassDeclaration({ abstract: boolean, attributes: AttributesProp, baseType: Children, doc: Children, file: boolean, interfaceTypes: Children[], internal: boolean, name: string, partial: boolean, primaryConstructor: ParameterProps[], private: boolean, protected: boolean, public: boolean, refkey: Refkey, sealed: boolean, static: boolean, typeParameters: (string | TypeParameterProps)[],}).children(children)
abstract | optionalboolean |
attributes | optionalAttributesProp Define attributes to attach |
baseType | optionalChildren Base class that this class extends |
doc | optionalChildren Doc comment |
file | optionalboolean |
interfaceTypes | optionalChildren[] Interfaces this class implements |
internal | optionalboolean |
name | string |
partial | optionalboolean |
primaryConstructor | optionalParameterProps[] Set the primary constructor parameters |
private | optionalboolean |
protected | optionalboolean |
public | optionalboolean |
refkey | optionalRefkey |
sealed | optionalboolean |
static | optionalboolean |
typeParameters | optional(string | TypeParameterProps)[] Type parameters for the class |
Example
Section titled “Example”<ClassDeclaration public name="MyClass"> <ClassMember public name="MyField" type="int" /> <ClassConstructor> <Parameter name="value" type="int" /> this.MyField = value; </ClassConstructor></ClassDeclaration>
This will produce:
public class MyClass{ public int MyField; public MyClass(int value) { this.MyField = value; }}