C# 在Typescript中创建类的数组

C# 在Typescript中创建类的数组,c#,angular,typescript,C#,Angular,Typescript,我如何创建类的数组,然后在其中推送一些类,我只需要创建和 用C# 属性 checksGraph :CheckBoxListItem; graphModel:Graph; 构造函数 constructor(private el:ElementRef, private renderer:Renderer) { this.checksGraph = new CheckBoxListItem(); this.graphModel = new Graph(); } 问题 pu

我如何创建类的数组,然后在其中推送一些类,我只需要创建和

用C#

属性

  checksGraph :CheckBoxListItem;
  graphModel:Graph;
构造函数

constructor(private el:ElementRef, private renderer:Renderer) { 


  this.checksGraph = new CheckBoxListItem();
  this.graphModel = new Graph();
}
问题

  pushItem(){

    this.checksGraph.DisplayName=displayName;
    this.checksGraph.Value=value;
    this.checksGraph.IsChecked=check;      
    this.graphModel.checkedItems.push(this.checksGraph); 
 }
由于checkedItems未定义,此行无法运行

this.graphModel.checkedItems.push(this.checksGraph)

也不能用

this.graphModel.checkedItems=新的CheckBoxListItem[50]


这抛出类型错误:CheckBoxListItem[50]不是构造函数。

图形中,更改类定义

checkedItems:CheckBoxListItem[]


checkedItems:CheckBoxListItem[]=[]

在此之后是否需要在构造函数中初始化属性?当我推送某个类时,前面的所有元素都复制相同的属性
constructor(private el:ElementRef, private renderer:Renderer) { 


  this.checksGraph = new CheckBoxListItem();
  this.graphModel = new Graph();
}
  pushItem(){

    this.checksGraph.DisplayName=displayName;
    this.checksGraph.Value=value;
    this.checksGraph.IsChecked=check;      
    this.graphModel.checkedItems.push(this.checksGraph); 
 }