插件中使用new System.Collections.Generic.List$1<string>(cnt)创建对象失败

我尝试使用new System.Collections.Generic.List$1<string>(cnt)创建一个对象,但是运行是报错csharp_1.System.Collections.Generic.List$1 is not a constructor。这是为什么呢
已邀请:

pero

赞同来自:

我在开发一个purets环境的插件,插件中需要读取二进制文件,所以使用了
FairyGUI.Utils.ByteBuffer对象来存二进制数据,我想要更改buffer.stringTable =xxx,这里的xxx需要是System.Array$1类型,但是我发现System.Array$1只是哥interface接口,所以用了let arr = System.Collections.Generic.List$1<string>(10) 来创建对象,再使用arr.toArray()来生成System.Collections.Generic.List$1,类型检查通过,但是运行报错。

pero

赞同来自:

哦哦,解决了,是我不熟悉,要
$generic(System.Collections.Generic.List$1, System.String)这样使用

sd1840888

赞同来自:

ts的泛型只是用来在编辑器里检测一致性的,还是需要通过puer.$generic来注册对应的类型

要回复问题请先登录注册