本文整理汇总了C#中System.Collections.ArrayList.MoveNext方法的典型用法代码示例。如果您正苦于以下问题:C# System.Collections.ArrayList.MoveNext方法的具体用法?C# System.Collections.ArrayList.MoveNext怎么用?C# System.Collections.ArrayList.MoveNext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.ArrayList
的用法示例。
在下文中一共展示了System.Collections.ArrayList.MoveNext方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddAll
/// <summary>
/// Adds all the elements of the specified collection that are not present to the list.
/// </summary>
/// <param name="c">Collection where the new elements will be added</param>
/// <returns>Returns true if at least one element was added, false otherwise.</returns>
public bool AddAll(System.Collections.ICollection c)
{
System.Collections.IEnumerator e = new System.Collections.ArrayList(c).GetEnumerator();
bool added = false;
while (e.MoveNext() == true)
{
if (this.Add(e.Current) == true)
added = true;
}
return added;
}
示例2: AddAll
/// <summary>
/// Adds all of the elements of the "c" collection to the "target" collection.
/// </summary>
/// <param gridTemplateName="target">Collection where the new elements will be added.</param>
/// <param gridTemplateName="c">Collection whose elements will be added.</param>
/// <returns>Returns true if at least one element was added, false otherwise.</returns>
public static bool AddAll(System.Collections.ICollection target, System.Collections.ICollection c)
{
System.Collections.IEnumerator e = new System.Collections.ArrayList(c).GetEnumerator();
bool added = false;
//Reflection. Invoke "addAll" method for proprietary classes
System.Reflection.MethodInfo method;
try
{
method = target.GetType().GetMethod("addAll");
if (method != null)
added = (bool) method.Invoke(target, new System.Object[] {c});
else
{
method = target.GetType().GetMethod("Add");
while (e.MoveNext() == true)
{
bool tempBAdded = (int) method.Invoke(target, new System.Object[] {e.Current}) >= 0;
added = added ? added : tempBAdded;
}
}
}
catch (System.Exception ex)
{
throw ex;
}
return added;
}
示例3: RetainAll
/// <summary>
/// Retains the elements in the target collection that are contained in the specified collection
/// </summary>
/// <param gridTemplateName="target">Collection where the elements will be removed.</param>
/// <param gridTemplateName="c">Elements to be retained in the target collection.</param>
/// <returns>true</returns>
public static bool RetainAll(System.Collections.ICollection target, System.Collections.ICollection c)
{
System.Collections.IEnumerator e = new System.Collections.ArrayList(target).GetEnumerator();
System.Collections.ArrayList al = new System.Collections.ArrayList(c);
//Reflection. Invoke "retainAll" method for proprietary classes or "Remove" for each element in the collection
System.Reflection.MethodInfo method;
try
{
method = c.GetType().GetMethod("retainAll");
if (method != null)
method.Invoke(target, new System.Object[] {c});
else
{
method = c.GetType().GetMethod("Remove");
while (e.MoveNext() == true)
{
if (al.Contains(e.Current) == false)
method.Invoke(target, new System.Object[] {e.Current});
}
}
}
catch (System.Exception ex)
{
throw ex;
}
return true;
}
示例4: AddAll
/// <summary>
/// Adds all the elements contained in the specified collection.
/// </summary>
/// <param name="collection">The collection used to extract the elements that will be added.</param>
/// <returns>Returns true if all the elements were successfuly added. Otherwise returns false.</returns>
public virtual bool AddAll(System.Collections.ICollection collection)
{
bool result = false;
if (collection!=null)
{
System.Collections.IEnumerator tempEnumerator = new System.Collections.ArrayList(collection).GetEnumerator();
while (tempEnumerator.MoveNext())
{
if (tempEnumerator.Current != null)
result = this.Add(tempEnumerator.Current);
}
}
return result;
}
示例5: RemoveAll
/// <summary>
/// Removes all the elements contained into the specified collection.
/// </summary>
/// <param name="collection">The collection used to extract the elements that will be removed.</param>
/// <returns>Returns true if all the elements were successfuly removed. Otherwise returns false.</returns>
public virtual bool RemoveAll(System.Collections.ICollection collection)
{
bool result = false;
System.Collections.IEnumerator tempEnumerator = new System.Collections.ArrayList(collection).GetEnumerator();
while (tempEnumerator.MoveNext())
{
if (this.Contains(tempEnumerator.Current))
result = this.Remove(tempEnumerator.Current);
}
return result;
}
示例6: ContainsAll
/// <summary>
/// Verifies if all the elements of the specified collection are contained into the current collection.
/// </summary>
/// <param name="collection">The collection used to extract the elements that will be verified.</param>
/// <returns>Returns true if all the elements are contained in the collection. Otherwise returns false.</returns>
public virtual bool ContainsAll(System.Collections.ICollection collection)
{
bool result = false;
System.Collections.IEnumerator tempEnumerator = new System.Collections.ArrayList(collection).GetEnumerator();
while (tempEnumerator.MoveNext())
if (!(result = this.Contains(tempEnumerator.Current)))
break;
return result;
}