[英]String List in ActionScript-3?
如何在ActionScript-3中獲得字符串列表 ? 我不想只使用數組並總是檢查類型或類型易受攻擊。 如果我可以使數組類型特定,那將對我有幫助。 在C#中,我可以執行以下操作:
List<string> list = new List<string>();
list.Add("hello world");
string str = list[0];
我希望我可以在AS-3中做更多或更少的事情。
您可以使用Vector
類型,如下所示:
var list:Vector.<String> = new <String>[];
// or new Vector.<String>();
list.push("hello world");
var str:String = list[0];
請注意,AS3的Vector
類缺少C#的List<T>
某些功能Remove()
例如Remove()
,並且包括一些您可以在其他C#類中找到的功能,例如pop()
,通常在Stack<T>
。
在AS3中,您可以使用Vector
數據類型。
Vector
類的工作方式與您所需的相同。
請參閱http://help.adobe.com/zh_CN/FlashPlatform/reference/actionscript/3/Vector.html 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.