实现了IEnumerable接口的GetEnumerator 即可使用 Foreach遍历,返回一个IEnumerator对象
#region 程序集 mscorlib.dll, v4.0.0.0
// C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\mscorlib.dll
#endregion //此处的ArrayList内部实现了
GetEnumerator方法,故可以遍历。
此方法是虚函数方式实现,故可以被重写 override.
如果不实现上面的那个方法,对象就不可能返回一个IEnumerator对象,没有IEnumerator对象,就不可能调用方法MoveNext(),调用不了MoveNext,就不可能循环的了 using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime;
using System.Runtime.InteropServices;
using System.Security; namespace System.Collections
{
// 摘要:
// 使用大小会根据需要动态增加的数组来实现 System.Collections.IList 接口。
[Serializable]
[ComVisible(true)]
[DebuggerDisplay("Count = {Count}")]
[DebuggerTypeProxy(typeof(ArrayList.ArrayListDebugView))]
public class ArrayList : IList, ICollection, IEnumerable, ICloneable
{
// 摘要:
// 初始化 System.Collections.ArrayList 类的新实例,该实例为空并且具有默认初始容量。
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
public ArrayList();
//
// 摘要:
// 初始化 System.Collections.ArrayList 类的新实例,该实例包含从指定集合复制的元素并且具有与所复制的元素数相同的初始容量。
//
// 参数:
// c:
// System.Collections.ICollection,它的元素被复制到新列表中。
//
// 异常:
// System.ArgumentNullException:
// c 为 null。
public ArrayList(ICollection c);
//
// 摘要:
// 初始化 System.Collections.ArrayList 类的新实例,该实例为空并且具有指定的初始容量。
//
// 参数:
// capacity:
// 新列表最初可以存储的元素数。
//
// 异常:
// System.ArgumentOutOfRangeException:
// capacity 小于零。
public ArrayList(int capacity); // 摘要:
// 获取或设置 System.Collections.ArrayList 可包含的元素数。
//
// 返回结果:
// System.Collections.ArrayList 可包含的元素数。
//
// 异常:
// System.ArgumentOutOfRangeException:
// System.Collections.ArrayList.Capacity 设置为小于 System.Collections.ArrayList.Count
// 的值。
//
// System.OutOfMemoryException:
// 系统中没有足够的可用内存。
public virtual int Capacity { get; set; }
//
// 摘要:
// 获取 System.Collections.ArrayList 中实际包含的元素数。
//
// 返回结果:
// System.Collections.ArrayList 中实际包含的元素数。
public virtual int Count { get; }
//
// 摘要:
// 获取一个值,该值指示 System.Collections.ArrayList 是否具有固定大小。
//
// 返回结果:
// 如果 System.Collections.ArrayList 具有固定大小,则为 true;否则为 false。 默认值为 false。
public virtual bool IsFixedSize { get; }
//
// 摘要:
// 获取一个值,该值指示 System.Collections.ArrayList 是否为只读。
//
// 返回结果:
// 如果 System.Collections.ArrayList 为只读,则为 true;否则为 false。 默认值为 false。
public virtual bool IsReadOnly { get; }
//
// 摘要:
// 获取一个值,该值指示是否同步对 System.Collections.ArrayList 的访问(线程安全)。
//
// 返回结果:
// 如果对 System.Collections.ArrayList 的访问是同步的(线程安全),则为 true;否则为 false。 默认值为 false。
public virtual bool IsSynchronized { get; }
//
// 摘要:
// 获取可用于同步对 System.Collections.ArrayList 的访问的对象。
//
// 返回结果:
// 可用于同步对 System.Collections.ArrayList 的访问的对象。
public virtual object SyncRoot { get; } // 摘要:
// 获取或设置位于指定索引处的元素。
//
// 参数:
// index:
// 要获得或设置的元素从零开始的索引。
//
// 返回结果:
// 位于指定索引处的元素。
//
// 异常:
// System.ArgumentOutOfRangeException:
// index 小于零。 - 或 - index 等于或大于 System.Collections.ArrayList.Count。
public virtual object this[int index] { get; set; } // 摘要:
// 为特定的 System.Collections.IList 创建 System.Collections.ArrayList 包装。
//
// 参数:
// list:
// 要包装的 System.Collections.IList。
//
// 返回结果:
// System.Collections.IList 周围的 System.Collections.ArrayList 包装。
//
// 异常:
// System.ArgumentNullException:
// list 为 null。
public static ArrayList Adapter(IList list);
//
// 摘要:
// 将对象添加到 System.Collections.ArrayList 的结尾处。
//
// 参数:
// value:
// 要添加到 System.Collections.ArrayList 的末尾处的 System.Object。 该值可以为 null。
//
// 返回结果:
// System.Collections.ArrayList 索引,已在此处添加了 value。
//
// 异常:
// System.NotSupportedException:
// System.Collections.ArrayList 为只读。 - 或 - System.Collections.ArrayList 具有固定大小。
public virtual int Add(object value);
//
// 摘要:
// 将 System.Collections.ICollection 的元素添加到 System.Collections.ArrayList 的末尾。
//
// 参数:
// c:
// System.Collections.ICollection,其元素应被添加到 System.Collections.ArrayList 的末尾。
// 集合本身不能为 null,但它可以包含为 null 的元素。
//
// 异常:
// System.ArgumentNullException:
// c 为 null。
//
// System.NotSupportedException:
// System.Collections.ArrayList 为只读。 - 或 - System.Collections.ArrayList 具有固定大小。
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
public virtual void AddRange(ICollection c);
//
// 摘要:
// 使用默认的比较器在整个已排序的 System.Collections.ArrayList 中搜索元素,并返回该元素从零开始的索引。
//
// 参数:
// value:
// 要定位的 System.Object。 该值可以为 null。
//
// 返回结果:
// 如果找到 value,则为已排序的 System.Collections.ArrayList 中从零开始的 value 索引;否则为一个负数,它是大于
// value 的下一个元素索引的按位求补,如果没有更大的元素,则为 System.Collections.ArrayList.Count 的按位求补。
//
// 异常:
// System.ArgumentException:
// 无论是 value 还是 System.Collections.ArrayList 的元素都不实现 System.IComparable 接口。
//
// System.InvalidOperationException:
// value 与 System.Collections.ArrayList 的元素类型不同。
public virtual int BinarySearch(object value);
//
// 摘要:
// 使用指定的比较器在整个已排序的 System.Collections.ArrayList 中搜索元素,并返回该元素从零开始的索引。
//
// 参数:
// value:
// 要定位的 System.Object。 该值可以为 null。
//
// comparer:
// 比较元素时要使用的 System.Collections.IComparer 实现。 - 或 - null 表示使用默认比较器,即每个元素的 System.IComparable
// 实现。
//
// 返回结果:
// 如果找到 value,则为已排序的 System.Collections.ArrayList 中从零开始的 value 索引;否则为一个负数,它是大于
// value 的下一个元素索引的按位求补,如果没有更大的元素,则为 System.Collections.ArrayList.Count 的按位求补。
//
// 异常:
// System.ArgumentException:
// comparer 为 null,而且 value 和 System.Collections.ArrayList 的元素都不实现 System.IComparable
// 接口。
//
// System.InvalidOperationException:
// comparer 为 null,而且 value 与 System.Collections.ArrayList 的元素不属于同一类型。
public virtual int BinarySearch(object value, IComparer comparer);
//
// 摘要:
// 使用指定的比较器在已排序 System.Collections.ArrayList 的某个元素范围中搜索元素,并返回该元素从零开始的索引。
//
// 参数:
// index:
// 要搜索的范围从零开始的起始索引。
//
// count:
// 要搜索的范围的长度。
//
// value:
// 要定位的 System.Object。 该值可以为 null。
//
// comparer:
// 比较元素时要使用的 System.Collections.IComparer 实现。 - 或 - null 表示使用默认比较器,即每个元素的 System.IComparable
// 实现。
//
// 返回结果:
// 如果找到 value,则为已排序的 System.Collections.ArrayList 中从零开始的 value 索引;否则为一个负数,它是大于
// value 的下一个元素索引的按位求补,如果没有更大的元素,则为 System.Collections.ArrayList.Count 的按位求补。
//
// 异常:
// System.ArgumentException:
// index 和 count 不表示 System.Collections.ArrayList 中的有效范围。 - 或 - comparer 为 null,而且
// value 和 System.Collections.ArrayList 的元素都不实现 System.IComparable 接口。
//
// System.InvalidOperationException:
// comparer 为 null,而且 value 与 System.Collections.ArrayList 的元素不属于同一类型。
//
// System.ArgumentOutOfRangeException:
// index 小于零。 - 或 - count 小于零。
public virtual int BinarySearch(int index, int count, object value, IComparer comparer);
//
// 摘要:
// 从 System.Collections.ArrayList 中移除所有元素。
//
// 异常:
// System.NotSupportedException:
// System.Collections.ArrayList 为只读。 - 或 - System.Collections.ArrayList 具有固定大小。
public virtual void Clear();
//
// 摘要:
// 创建 System.Collections.ArrayList 的浅表副本。
//
// 返回结果:
// System.Collections.ArrayList 的浅表副本。
public virtual object Clone();
//
// 摘要:
// 确定某元素是否在 System.Collections.ArrayList 中。
//
// 参数:
// item:
// 要在 System.Collections.ArrayList 中查找的 System.Object。 该值可以为 null。
//
// 返回结果:
// 如果在 System.Collections.ArrayList 中找到 item,则为 true;否则为 false。
public virtual bool Contains(object item);
//
// 摘要:
// 从目标数组的开头开始将整个 System.Collections.ArrayList 复制到兼容的一维 System.Array 中。
//
// 参数:
// array:
// 作为从 System.Collections.ArrayList 复制的元素的目标的一维 System.Array。 System.Array 必须具有从零开始的索引。
//
// 异常:
// System.ArgumentNullException:
// array 为 null。
//
// System.ArgumentException:
// array 是多维的。 - 或 - 源 System.Collections.ArrayList 中的元素数大于目标 array 可包含的元素数。
//
// System.InvalidCastException:
// 源 System.Collections.ArrayList 的类型无法自动转换为目标 array 的类型。
public virtual void CopyTo(Array array);
//
// 摘要:
// 从目标数组的指定索引处开始将整个 System.Collections.ArrayList 复制到兼容的一维 System.Array。
//
// 参数:
// array:
// 作为从 System.Collections.ArrayList 复制的元素的目标的一维 System.Array。 System.Array 必须具有从零开始的索引。
//
// arrayIndex:
// array 中从零开始的索引,从此索引处开始进行复制。
//
// 异常:
// System.ArgumentNullException:
// array 为 null。
//
// System.ArgumentOutOfRangeException:
// arrayIndex 小于零。
//
// System.ArgumentException:
// array 是多维的。 - 或 - 源 System.Collections.ArrayList 中的元素数目大于从 arrayIndex 到目标
// array 末尾之间的可用空间。
//
// System.InvalidCastException:
// 源 System.Collections.ArrayList 的类型无法自动转换为目标 array 的类型。
public virtual void CopyTo(Array array, int arrayIndex);
//
// 摘要:
// 从目标数组的指定索引处开始,将一定范围的元素从 System.Collections.ArrayList 复制到兼容的一维 System.Array
// 中。
//
// 参数:
// index:
// 源 System.Collections.ArrayList 中复制开始位置的从零开始的索引。
//
// array:
// 作为从 System.Collections.ArrayList 复制的元素的目标的一维 System.Array。 System.Array 必须具有从零开始的索引。
//
// arrayIndex:
// array 中从零开始的索引,从此索引处开始进行复制。
//
// count:
// 要复制的元素数。
//
// 异常:
// System.ArgumentNullException:
// array 为 null。
//
// System.ArgumentOutOfRangeException:
// index 小于零。 - 或 - arrayIndex 小于零。 - 或 - count 小于零。
//
// System.ArgumentException:
// array 是多维的。 - 或 - index 等于或大于源 System.Collections.ArrayList 的 System.Collections.ArrayList.Count。
// - 或 - 从 index 到源 System.Collections.ArrayList 的末尾的元素数大于从 arrayIndex 到目标 array
// 的末尾的可用空间。
//
// System.InvalidCastException:
// 源 System.Collections.ArrayList 的类型无法自动转换为目标 array 的类型。
public virtual void CopyTo(int index, Array array, int arrayIndex, int count);
//
// 摘要:
// 返回具有固定大小的 System.Collections.ArrayList 包装。
//
// 参数:
// list:
// 要包装的 System.Collections.ArrayList。
//
// 返回结果:
// 具有固定大小的 System.Collections.ArrayList 包装。
//
// 异常:
// System.ArgumentNullException:
// list 为 null。
public static ArrayList FixedSize(ArrayList list);
//
// 摘要:
// 返回具有固定大小的 System.Collections.IList 包装。
//
// 参数:
// list:
// 要包装的 System.Collections.IList。
//
// 返回结果:
// 具有固定大小的 System.Collections.IList 包装。
//
// 异常:
// System.ArgumentNullException:
// list 为 null。
public static IList FixedSize(IList list);
//
// 摘要:
// 返回整个 System.Collections.ArrayList 的一个枚举器。
//
// 返回结果:
// 用于整个 System.Collections.ArrayList 的 System.Collections.IEnumerator。
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
public virtual IEnumerator GetEnumerator();
//
// 摘要:
// 返回 System.Collections.ArrayList 中某个范围内的元素的枚举器。
//
// 参数:
// index:
// 枚举器应引用的 System.Collections.ArrayList 部分从零开始的起始索引。
//
// count:
// 枚举器应引用的 System.Collections.ArrayList 部分中的元素数。
//
// 返回结果:
// System.Collections.ArrayList 中指定范围内的元素的 System.Collections.IEnumerator。
//
// 异常:
// System.ArgumentOutOfRangeException:
// index 小于零。 - 或 - count 小于零。
//
// System.ArgumentException:
// index 和 count 未指定 System.Collections.ArrayList 中的有效范围。
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
public virtual IEnumerator GetEnumerator(int index, int count);
//
// 摘要:
// 返回 System.Collections.ArrayList,它表示源 System.Collections.ArrayList 中元素的子集。
//
// 参数:
// index:
// 范围开始处的从零开始的 System.Collections.ArrayList 索引。
//
// count:
// 范围中的元素数。
//
// 返回结果:
// System.Collections.ArrayList,它表示源 System.Collections.ArrayList 中元素的子集。
//
// 异常:
// System.ArgumentOutOfRangeException:
// index 小于零。 - 或 - count 小于零。
//
// System.ArgumentException:
// index 和 count 不表示 System.Collections.ArrayList 中元素的有效范围。
public virtual ArrayList GetRange(int index, int count);
//
// 摘要:
// 搜索指定的 System.Object,并返回整个 System.Collections.ArrayList 中第一个匹配项的从零开始的索引。
//
// 参数:
// value:
// 要在 System.Collections.ArrayList 中查找的 System.Object。 该值可以为 null。
//
// 返回结果:
// 如果在整个 System.Collections.ArrayList 中找到 value 的第一个匹配项,则为该项的从零开始的索引;否则为 -1。
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
public virtual int IndexOf(object value);
//
// 摘要:
// 搜索指定的 System.Object,并返回 System.Collections.ArrayList 中从指定索引到最后一个元素的元素范围内第一个匹配项的从零开始的索引。
//
// 参数:
// value:
// 要在 System.Collections.ArrayList 中查找的 System.Object。 该值可以为 null。
//
// startIndex:
// 从零开始的搜索的起始索引。 空列表中 0(零)为有效值。
//
// 返回结果:
// 如果在 System.Collections.ArrayList 中从 startIndex 到最后一个元素的元素范围内找到 value 的第一个匹配项,则为该项的从零开始的索引;否则为
// -1。
//
// 异常:
// System.ArgumentOutOfRangeException:
// startIndex 不在 System.Collections.ArrayList 的有效索引范围内。
public virtual int IndexOf(object value, int startIndex);
//
// 摘要:
// 搜索指定的 System.Object,并返回 System.Collections.ArrayList 中从指定的索引开始并包含指定的元素数的元素范围内第一个匹配项的从零开始的索引。
//
// 参数:
// value:
// 要在 System.Collections.ArrayList 中查找的 System.Object。 该值可以为 null。
//
// startIndex:
// 从零开始的搜索的起始索引。 空列表中 0(零)为有效值。
//
// count:
// 要搜索的部分中的元素数。
//
// 返回结果:
// 如果在 System.Collections.ArrayList 中从 startIndex 开始并包含 count 个元素的元素范围内找到 value
// 的第一个匹配项,则为该项的从零开始的索引;否则为 -1。
//
// 异常:
// System.ArgumentOutOfRangeException:
// startIndex 不在 System.Collections.ArrayList 的有效索引范围内。 - 或 - count 小于零。 - 或
// - startIndex 和 count 未指定 System.Collections.ArrayList 中的有效部分。
public virtual int IndexOf(object value, int startIndex, int count);
//
// 摘要:
// 将元素插入 System.Collections.ArrayList 的指定索引处。
//
// 参数:
// index:
// 从零开始的索引,应在该位置插入 value。
//
// value:
// 要插入的 System.Object。 该值可以为 null。
//
// 异常:
// System.ArgumentOutOfRangeException:
// index 小于零。 - 或 - index 大于 System.Collections.ArrayList.Count。
//
// System.NotSupportedException:
// System.Collections.ArrayList 为只读。 - 或 - System.Collections.ArrayList 具有固定大小。
public virtual void Insert(int index, object value);
//
// 摘要:
// 将集合中的某个元素插入 System.Collections.ArrayList 的指定索引处。
//
// 参数:
// index:
// 应在此处插入新元素的从零开始的索引。
//
// c:
// System.Collections.ICollection,应将其元素插入到 System.Collections.ArrayList 中。 集合本身不能为
// null,但它可以包含为 null 的元素。
//
// 异常:
// System.ArgumentNullException:
// c 为 null。
//
// System.ArgumentOutOfRangeException:
// index 小于零。 - 或 - index 大于 System.Collections.ArrayList.Count。
//
// System.NotSupportedException:
// System.Collections.ArrayList 为只读。 - 或 - System.Collections.ArrayList 具有固定大小。
public virtual void InsertRange(int index, ICollection c);
//
// 摘要:
// 搜索指定的 System.Object,并返回整个 System.Collections.ArrayList 中最后一个匹配项的从零开始的索引。
//
// 参数:
// value:
// 要在 System.Collections.ArrayList 中查找的 System.Object。 该值可以为 null。
//
// 返回结果:
// 如果在整个 System.Collections.ArrayList 中找到 value 的最后一个匹配项,则为该项的从零开始的索引;否则为 -1。
public virtual int LastIndexOf(object value);
//
// 摘要:
// 搜索指定的 System.Object,并返回 System.Collections.ArrayList 中从第一个元素到指定索引的元素范围内最后一个匹配项的从零开始的索引。
//
// 参数:
// value:
// 要在 System.Collections.ArrayList 中查找的 System.Object。 该值可以为 null。
//
// startIndex:
// 向后搜索的从零开始的起始索引。
//
// 返回结果:
// 如果在 System.Collections.ArrayList 中从第一个元素到 startIndex 的元素范围内找到 value 的最后一个匹配项,则为该项的从零开始的索引;否则为
// -1。
//
// 异常:
// System.ArgumentOutOfRangeException:
// startIndex 不在 System.Collections.ArrayList 的有效索引范围内。
public virtual int LastIndexOf(object value, int startIndex);
//
// 摘要:
// 搜索指定的 System.Object,并返回 System.Collections.ArrayList 中包含指定的元素数并在指定索引处结束的元素范围内最后一个匹配项的从零开始的索引。
//
// 参数:
// value:
// 要在 System.Collections.ArrayList 中查找的 System.Object。 该值可以为 null。
//
// startIndex:
// 向后搜索的从零开始的起始索引。
//
// count:
// 要搜索的部分中的元素数。
//
// 返回结果:
// 如果在 System.Collections.ArrayList 中包含 count 个元素、在 startIndex 处结尾的元素范围内找到 value
// 的最后一个匹配项,则为该项的从零开始的索引;否则为 -1。
//
// 异常:
// System.ArgumentOutOfRangeException:
// startIndex 不在 System.Collections.ArrayList 的有效索引范围内。 - 或 - count 小于零。 - 或
// - startIndex 和 count 未指定 System.Collections.ArrayList 中的有效部分。
public virtual int LastIndexOf(object value, int startIndex, int count);
//
// 摘要:
// 返回只读的 System.Collections.ArrayList 包装。
//
// 参数:
// list:
// 要包装的 System.Collections.ArrayList。
//
// 返回结果:
// list 周围的只读 System.Collections.ArrayList 包装。
//
// 异常:
// System.ArgumentNullException:
// list 为 null。
public static ArrayList ReadOnly(ArrayList list);
//
// 摘要:
// 返回只读的 System.Collections.IList 包装。
//
// 参数:
// list:
// 要包装的 System.Collections.IList。
//
// 返回结果:
// list 周围的只读 System.Collections.IList 包装。
//
// 异常:
// System.ArgumentNullException:
// list 为 null。
public static IList ReadOnly(IList list);
//
// 摘要:
// 从 System.Collections.ArrayList 中移除特定对象的第一个匹配项。
//
// 参数:
// obj:
// 要从 System.Collections.ArrayList 移除的 System.Object。 该值可以为 null。
//
// 异常:
// System.NotSupportedException:
// System.Collections.ArrayList 为只读。 - 或 - System.Collections.ArrayList 具有固定大小。
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
public virtual void Remove(object obj);
//
// 摘要:
// 移除 System.Collections.ArrayList 的指定索引处的元素。
//
// 参数:
// index:
// 要移除的元素的从零开始的索引。
//
// 异常:
// System.ArgumentOutOfRangeException:
// index 小于零。 - 或 - index 等于或大于 System.Collections.ArrayList.Count。
//
// System.NotSupportedException:
// System.Collections.ArrayList 为只读。 - 或 - System.Collections.ArrayList 具有固定大小。
public virtual void RemoveAt(int index);
//
// 摘要:
// 从 System.Collections.ArrayList 中移除一定范围的元素。
//
// 参数:
// index:
// 要移除的元素的范围从零开始的起始索引。
//
// count:
// 要移除的元素数。
//
// 异常:
// System.ArgumentOutOfRangeException:
// index 小于零。 - 或 - count 小于零。
//
// System.ArgumentException:
// index 和 count 不表示 System.Collections.ArrayList 中元素的有效范围。
//
// System.NotSupportedException:
// System.Collections.ArrayList 为只读。 - 或 - System.Collections.ArrayList 具有固定大小。
public virtual void RemoveRange(int index, int count);
//
// 摘要:
// 返回 System.Collections.ArrayList,它的元素是指定值的副本。
//
// 参数:
// value:
// 要在新 System.Collections.ArrayList 中对其进行多次复制的 System.Object。 该值可以为 null。
//
// count:
// value 应被复制的次数。
//
// 返回结果:
// 具有 count 所指定的元素数的 System.Collections.ArrayList,其中的所有元素都是 value 的副本。
//
// 异常:
// System.ArgumentOutOfRangeException:
// count 小于零。
public static ArrayList Repeat(object value, int count);
//
// 摘要:
// 将整个 System.Collections.ArrayList 中元素的顺序反转。
//
// 异常:
// System.NotSupportedException:
// System.Collections.ArrayList 为只读。
public virtual void Reverse();
//
// 摘要:
// 将指定范围中元素的顺序反转。
//
// 参数:
// index:
// 要反转的范围的从零开始的起始索引。
//
// count:
// 要反转的范围内的元素数。
//
// 异常:
// System.ArgumentOutOfRangeException:
// index 小于零。 - 或 - count 小于零。
//
// System.ArgumentException:
// index 和 count 不表示 System.Collections.ArrayList 中元素的有效范围。
//
// System.NotSupportedException:
// System.Collections.ArrayList 为只读。
public virtual void Reverse(int index, int count);
//
// 摘要:
// 将集合中的元素复制到 System.Collections.ArrayList 中一定范围的元素上。
//
// 参数:
// index:
// 从零开始的 System.Collections.ArrayList 索引,从该位置开始复制 c 的元素。
//
// c:
// System.Collections.ICollection,要将其元素复制到 System.Collections.ArrayList 中。 集合本身不能为
// null,但它可以包含为 null 的元素。
//
// 异常:
// System.ArgumentOutOfRangeException:
// index 小于零。 - 或 - index 加上 c 中的元素数大于 System.Collections.ArrayList.Count。
//
// System.ArgumentNullException:
// c 为 null。
//
// System.NotSupportedException:
// System.Collections.ArrayList 为只读。
public virtual void SetRange(int index, ICollection c);
//
// 摘要:
// 对整个 System.Collections.ArrayList 中的元素进行排序。
//
// 异常:
// System.NotSupportedException:
// System.Collections.ArrayList 为只读。
public virtual void Sort();
//
// 摘要:
// 使用指定的比较器对整个 System.Collections.ArrayList 中的元素进行排序。
//
// 参数:
// comparer:
// 比较元素时要使用的 System.Collections.IComparer 实现。 - 或 - null 引用(Visual Basic 中为
// Nothing)将使用每个元数的 System.IComparable 实现。
//
// 异常:
// System.NotSupportedException:
// System.Collections.ArrayList 为只读。
//
// System.InvalidOperationException:
// 比较两个元素时出错。
public virtual void Sort(IComparer comparer);
//
// 摘要:
// 使用指定的比较器对 System.Collections.ArrayList 中某个范围内的元素进行排序。
//
// 参数:
// index:
// 要排序的范围的从零开始的起始索引。
//
// count:
// 要排序的范围的长度。
//
// comparer:
// 比较元素时要使用的 System.Collections.IComparer 实现。 - 或 - null 引用(Visual Basic 中为
// Nothing)将使用每个元数的 System.IComparable 实现。
//
// 异常:
// System.ArgumentOutOfRangeException:
// index 小于零。 - 或 - count 小于零。
//
// System.ArgumentException:
// index 和 count 未指定 System.Collections.ArrayList 中的有效范围。
//
// System.NotSupportedException:
// System.Collections.ArrayList 为只读。
//
// System.InvalidOperationException:
// 比较两个元素时出错。
public virtual void Sort(int index, int count, IComparer comparer);
//
// 摘要:
// 返回同步的(线程安全)System.Collections.ArrayList 包装。
//
// 参数:
// list:
// 要同步的 System.Collections.ArrayList。
//
// 返回结果:
// 同步的(线程安全)System.Collections.ArrayList 包装。
//
// 异常:
// System.ArgumentNullException:
// list 为 null。
public static ArrayList Synchronized(ArrayList list);
//
// 摘要:
// 返回同步的(线程安全)System.Collections.IList 包装。
//
// 参数:
// list:
// 要同步的 System.Collections.IList。
//
// 返回结果:
// 同步的(线程安全)System.Collections.IList 包装。
//
// 异常:
// System.ArgumentNullException:
// list 为 null。
public static IList Synchronized(IList list);
//
// 摘要:
// 将 System.Collections.ArrayList 的元素复制到新 System.Object 数组中。
//
// 返回结果:
// System.Object 数组,它包含 System.Collections.ArrayList 中元素的副本。
public virtual object[] ToArray();
//
// 摘要:
// 将 System.Collections.ArrayList 的元素复制到指定元素类型的新数组中。
//
// 参数:
// type:
// 要创建并向其复制元素的目标数组的元素 System.Type。
//
// 返回结果:
// 指定元素类型的数组,它包含 System.Collections.ArrayList 中元素的副本。
//
// 异常:
// System.ArgumentNullException:
// type 为 null。
//
// System.InvalidCastException:
// 源 System.Collections.ArrayList 的类型不能自动转换为指定类型。
[SecuritySafeCritical]
public virtual Array ToArray(Type type);
//
// 摘要:
// 将容量设置为 System.Collections.ArrayList 中元素的实际数目。
//
// 异常:
// System.NotSupportedException:
// System.Collections.ArrayList 为只读。 - 或 - System.Collections.ArrayList 具有固定大小。
public virtual void TrimToSize();
}
}
实现了IEnumerable接口的GetEnumerator 即可使用 Foreach遍历,返回一个IEnumerator对象的更多相关文章
- C# 索引器,实现IEnumerable接口的GetEnumerator()方法
当自定义类需要实现索引时,可以在类中实现索引器. 用Table作为例子,Table由多个Row组成,Row由多个Cell组成, 我们需要实现自定义的table[0],row[0] 索引器定义格式为 [ ...
- 第3章 springboot接口返回json 3-1 SpringBoot构造并返回一个json对象
数据的使用主要还是以JSON为主,我们不会去使用XML. 这个时候我们先不使用@RestController,我们使用之前SpringMVC的那种方式,就是@Controller. @Respons ...
- foreach为什么要实现IEnumerable接口而不是直接用IEnumerator接口
在.Net中,要想被foreach遍历,那么目标对象要实现IEnumerable或IEnumerable<T>接口,这个接口有一个方法,GetEnumerator(),返回一个IEnume ...
- C# 通过IEnumberable接口和IEnumerator接口实现自定义集合类型foreach功能
1.IEnumerator和IEnumerable的作用 其实IEnumerator和IEnumerable的作用很简单,就是让除数组和集合之外的类型也能支持foreach循环,至于foreach循环 ...
- 接口、索引器、Foreach的本质(学习笔记)
接口 什么是接口? 接口代表一种能力,和抽象类类似但比抽象类的抽象程度更高! 接口的定义: public interface IEat//定义一个接口 { void Eat(string food); ...
- IEnumerable<T> 接口和GetEnumerator 详解
IEnumerable<T> 接口 .NET Framework 4.6 and 4.5 公开枚举数,该枚举数支持在指定类型的集合上进行简单迭代. 若要浏览此类型的.NET Frame ...
- 你可能不知道的陷阱, IEnumerable接口
1. IEnumerable 与 IEnumerator IEnumerable枚举器接口的重要性,说一万句话都不过分.几乎所有集合都实现了这个接口,Linq的核心也依赖于这个万能的接口.C语言的 ...
- IEnumerable接口
IEnumerable接口顾名思义就是 可枚举的,可列举的. 接口也很简单,返回一个 枚举器对象 IEnumerator . [ComVisible(true), Guid("496B0AB ...
- IEnumerable接口的实现
对象要实现可以迭代需IEnumerable接口并实现GetEnumerator方法.一下简单例子 public class SPEnumerable<T> : IEnumerable { ...
随机推荐
- 赴美工作常识(Part 6 - 绿卡排队)
上一篇<赴美工作常识(Part 5 - 绿卡优先级)>解释完排队的优先级是怎么确定的,以及 PERM 和 I–140 表的意义,接下来就要解释一下队具体是怎么排的以及排到之后的 I–485 ...
- winform 通过webservice向服务器提交图片需要注意的地方
最近一个winform项目中需要通过拍照或者上传本地文件或者截图的方式把产品图片上传到服务器,最后选择了服务器部署webservice的方式来进行.其中遇到了一些问题记录下来. 不多说,直接上服务端代 ...
- 使用ruby过程中遇到安装gem失败的一些通用解决方案
ruby语言升级还是比较勤快的.但是数量众多的版本使得程序库的兼容性成了大问题.有些gem表示明确不支持某个特定版本以前的ruby,而有些gem则与较高的版本不兼容.再加上gem本身也有版本,简直是乱 ...
- 跟我一起云计算(3)——hbase
hbase HBase是一个分布式的.面向列的开源数据库,该技术来源于 Fay Chang 所撰写的Google论文“Bigtable:一个结构化数据的分布式存储系统”.就像Bigtable利用了Go ...
- AngularJS入门教程1--配置环境
首先需要下载AngualrJS,下载地址 https://angularjs.org/ 官方网站提供2种下载使用AngularJS方法: 1. 去GitHub下载 ,点击按钮会跳转到GitHub页面, ...
- redis系列-redis的连接
Redis 是完全开源免费的,遵守BSD协议,先进的key - value持久化产品.它通常被称为数据结构服务器,因为值(value)可以是 字符串(String), 哈希(Map), 列表(list ...
- sybase学习
安装 下载安装包, 解压到/opt/sybase,注意必须目录是这样的/opt/sybase/ASE-15_0/install/ ,因为RUN_DBSVR里面写死了/opt/sybase/ASE-15 ...
- MySQL账户安全设置
一般来说,安装完MySQL后,默认的用户是root,密码123456,外网不能访问. 有时候也希望在外网访问,则可以添加一个账户.建议不要用root. 如下表,存在安全问题: mysql> se ...
- fir.im Weekly - 如何打造真正的工程师文化
好的工程师,无法忍受低效且无趣的工作.优秀的技术团队应该自上而下的地推进技术平台化建设.DevOps.自动化构建.测试和部署流程,积极采用合适的第三方工具或创造工具,进行周期性的前沿技术分享等等. 先 ...
- 在Windows系统搭建.NET Core环境并创建运行ASP.NET网站
微软于6月27日在红帽DevNation峰会上 正式发布了.NET Core 1.0.ASP.NET 1.0和Entity Framework Core 1.0,其将全部支持Windows.OS X和 ...