简体   繁体   English

ActionScript-3中的字符串列表?

[英]String List in ActionScript-3?

How can I have a string list in ActionScript-3 ? 如何在ActionScript-3中获得字符串列表 I don't want to just use an array and always check for type or be type vulnerable. 我不想只使用数组并总是检查类型或类型易受攻击。 If I could make arrays type specific that would help me. 如果我可以使数组类型特定,那将对我有帮助。 In C# I can do: 在C#中,我可以执行以下操作:

List<string> list = new List<string>();
list.Add("hello world");
string str = list[0];

I wished I could do more or less the same in AS-3. 我希望我可以在AS-3中做更多或更少的事情。

You can use the Vector type, like this: 您可以使用Vector类型,如下所示:

var list:Vector.<String> = new <String>[];
//                      or new Vector.<String>();

list.push("hello world");
var str:String = list[0];

Note that AS3's Vector class lacks some functionality found in C#'s List<T> like Remove() , and includes some functionality you would find in other classes of C# such as pop() , typically found in Stack<T> . 请注意,AS3的Vector类缺少C#的List<T>某些功能Remove()例如Remove() ,并且包括一些您可以在其他C#类中找到的功能,例如pop() ,通常在Stack<T>

In AS3 you can use Vector datatype. 在AS3中,您可以使用Vector数据类型。

See More info on Vector data type 查看有关矢量数据类型的更多信息

Vector class works the same way as you need. Vector类的工作方式与您所需的相同。

See http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/Vector.html . 请参阅http://help.adobe.com/zh_CN/FlashPlatform/reference/actionscript/3/Vector.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM