关于ArrayList.Add。。。的问题

CinnXu 2003-04-26 08:08:58
System.Collections.ArrayList.Add() 和 System.Collections.ArrayList.AddRange()有什么区别啊

Add是不是添加一个对象到末尾,而AddRange是不是添加一个对象数组到末尾啊
...全文
234 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
perilla 2003-04-26
  • 打赏
  • 举报
回复
add表示添加一个对象到末尾
ArrayList.AddRange()将 ICollection 的元素添加到 ArrayList 的末尾。

Dim myAL As New ArrayList()
myAL.Add("The")
myAL.Add("quick")
myAL.Add("brown")
myAL.Add("fox")

' Creates and initializes a new Queue.
Dim myQueue As New Queue()
myQueue.Enqueue("jumped")
myQueue.Enqueue("over")
myQueue.Enqueue("the")
myQueue.Enqueue("lazy")
myQueue.Enqueue("dog")

' Displays the ArrayList and the Queue.
Console.WriteLine("The ArrayList initially contains the following:")
PrintValues(myAL, ControlChars.Tab)
Console.WriteLine("The Queue initially contains the following:")
PrintValues(myQueue, ControlChars.Tab)

' Copies the Queue elements to the end of the ArrayList.
myAL.AddRange(myQueue)

110,538

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧