添加一个或多个元素到数组的开头
Easp.List.UnShift content Easp.List.UnShift_ content
content | Array (数组) 或 String (字符串) |
准备添加元素的内容。 |
下列返回值仅Easp.List.UnShift_
方法
Object | ASP对象 |
返回一个新的Easp的List对象,原List对象不受影响。 |
当 content 为字符串时,就是添加一个元素;当 content 为数组时,就是添加多个元素。
使用Easp.List.UnShift_
方法在原数组的数据加上新添加的数据,组成新的数组对象,不改变原数组的数据。
'创建一个List对象 Set list = Easp.List.New list.Hash = "zero:零 one:壹 two:贰 three:叁" '使用数组同时添加两个元素 list.UnShift Array("a:aaa", "b:bbb") '取出为普通数组 arr = list.Hash '循环输出 For i = 0 To Ubound(arr) Easp.WN("arr("& i &") => " & arr(i)) Next本示例运行结果为:
arr(0) => a:aaa arr(1) => b:bbb arr(2) => zero:零 arr(3) => one:壹 arr(4) => two:贰 arr(5) => three:叁
'创建一个List对象 Set list = Easp.List.New list.Hash = "zero:零 one:壹 two:贰 three:叁" '取出为普通数组 Dim arr, arr2 arr = list.Hash '原数组 arr2 = list.UnShift_(Array("a:aaa", "b:bbb")).Hash '新数组 '循环输出 For i = 0 To Ubound(arr) Easp.WN("arr("& i &") => " & arr(i)) Next Easp.WN "============" For i = 0 To Ubound(arr2) Easp.WN("arr2("& i &") => " & arr2(i)) Next本示例运行结果为:
arr(0) => zero:零 arr(1) => one:壹 arr(2) => two:贰 arr(3) => three:叁 ============ arr2(0) => a:aaa arr2(1) => b:bbb arr2(2) => zero:零 arr2(3) => one:壹 arr2(4) => two:贰 arr2(5) => three:叁