1 using System; 2 using System.Collections; 3 public class SamplesArrayList { 4 5 public static void Main() { 6 7 // Creates and initializes a new ArrayList. 8 ArrayList myAL = new ArrayList(); 9 myAL.Add("Hello"); 10 myAL.Add("World"); 11 myAL.Add("!"); 12 13 // Displays the properties and values of the ArrayList. 14 Console.WriteLine( "myAL" ); 15 Console.WriteLine( " Count: {0}", myAL.Count ); 16 Console.WriteLine( " Capacity: {0}", myAL.Capacity ); 17 Console.Write( " Values:" ); 18 PrintValues( myAL ); 19 } 20 21 public static void PrintValues( IEnumerable myList ) { 22 foreach ( Object obj in myList ) 23 Console.Write( " {0}", obj ); 24 Console.WriteLine(); 25 } 26 27 } 28 29 30 /* 31 This code produces output similar to the following: 32 33 myAL 34 Count: 3 35 Capacity: 4 36 Values: Hello World ! 37 38 */
构造函数
| ArrayList() |
ArrayList 类的新实例,该实例为空并且具有默认初始容量。 |
| ArrayList(ICollection) |
ArrayList 类的新实例,该类包含从指定集合复制的元素,并具有与复制的元素数相同的初始容量。 |
| ArrayList(Int32) |
ArrayList 类的新实例,该实例为空并且具有指定的初始容量。 |
属性
| Capacity |
ArrayList 可包含的元素数。 |
| Count |
ArrayList 中实际包含的元素数。 |
| IsFixedSize |
ArrayList 是否具有固定大小。 |
| IsReadOnly |
ArrayList 是否为只读。 |
| IsSynchronized |
ArrayList 的访问(线程安全)。 |
| Item[Int32] |
获取或设置指定索引处的元素。 |
| SyncRoot |
ArrayList 的访问的对象。 |
方法
| Adapter(IList) |
ArrayList 包装。 |
| Add(Object) |
ArrayList 的结尾处。 |
| AddRange(ICollection) |
ArrayList 的末尾。 |
| BinarySearch(Int32, Int32, Object, IComparer) |
ArrayList 的某个元素范围中搜索元素,并返回该元素从零开始的索引。 |
| BinarySearch(Object) |
ArrayList 中搜索元素,并返回该元素从零开始的索引。 |
| BinarySearch(Object, IComparer) |
ArrayList 中搜索元素,并返回该元素从零开始的索引。 |
| Clear() |
ArrayList 中移除所有元素。 |
| Clone() |
ArrayList 的浅表副本。 |
| Contains(Object) |
ArrayList 中。 |
| CopyTo(Array) |
Array。 |
| CopyTo(Array, Int32) |
Array。 |
| CopyTo(Int32, Array, Int32, Int32) |
Array 中。 |
| Equals(Object) |
确定指定的对象是否等于当前对象。 (Inherited from Object) |
| FixedSize(ArrayList) |
ArrayList 包装。 |
| FixedSize(IList) |
IList 包装。 |
| GetEnumerator() |
ArrayList 的一个枚举器。 |
| GetEnumerator(Int32, Int32) |
ArrayList 中某个范围内的元素的枚举器。 |
| GetHashCode() |
作为默认哈希函数。 (Inherited from Object) |
| GetRange(Int32, Int32) |
ArrayList 中元素的子集。 |
| GetType() |
Type。 (Inherited from Object) |
| IndexOf(Object) |
ArrayList 中第一个匹配项的从零开始的索引。 |
| IndexOf(Object, Int32) |
ArrayList 中从指定索引到最后一个元素的元素范围内第一个匹配项的从零开始的索引。 |
| IndexOf(Object, Int32, Int32) |
ArrayList 中从指定的索引开始并包含指定的元素数的元素范围内第一个匹配项的从零开始的索引。 |
| Insert(Int32, Object) |
ArrayList 的指定索引处。 |
| InsertRange(Int32, ICollection) |
ArrayList 的指定索引处。 |
| LastIndexOf(Object) |
ArrayList 中最后一个匹配项的从零开始的索引。 |
| LastIndexOf(Object, Int32) |
ArrayList 中从第一个元素到指定索引的元素范围内最后一个匹配项的从零开始的索引。 |
| LastIndexOf(Object, Int32, Int32) |
ArrayList 中包含指定的元素数并在指定索引处结束的元素范围内最后一个匹配项的从零开始的索引。 |
| MemberwiseClone() |
Object 的浅表副本。 (Inherited from Object) |
| ReadOnly(ArrayList) |
ArrayList 包装。 |
| ReadOnly(IList) |
IList 包装。 |
| Remove(Object) |
ArrayList 中移除特定对象的第一个匹配项。 |
| RemoveAt(Int32) |
ArrayList 的指定索引处的元素。 |
| RemoveRange(Int32, Int32) |
ArrayList 中移除一定范围的元素。 |
| Repeat(Object, Int32) |
ArrayList,它的元素是指定值的副本。 |
| Reverse() |
ArrayList 中元素的顺序反转。 |
| Reverse(Int32, Int32) |
将指定范围中元素的顺序反转。 |
| SetRange(Int32, ICollection) |
ArrayList 中一定范围的元素上。 |
| Sort() |
ArrayList 中的元素进行排序。 |
| Sort(IComparer) |
ArrayList 中的元素进行排序。 |
| Sort(Int32, Int32, IComparer) |
ArrayList 中某个范围内的元素进行排序。 |
| Synchronized(ArrayList) |
ArrayList 包装。 |
| Synchronized(IList) |
IList 包装。 |
| ToArray() |
Object 数组中。 |
| ToArray(Type) |
ArrayList 的元素复制到指定元素类型的新数组中。 |
| ToString() |
返回表示当前对象的字符串。 (Inherited from Object) |
| TrimToSize() |
ArrayList 中元素的实际数目。 |