System.CodeDom.CodeTypeMemberCollection Class

Assembly: System.dll
Namespace: System.CodeDom
Summary
Represents a collection of CodeTypeMember objects.
C# Syntax:
[Serializable]
public class CodeTypeMemberCollection : CollectionBase
Remarks
Provides a simple collection object that can represent a set of CodeDOM type member objects.
See also:
System.CodeDom Namespace | CodeTypeMemberCollection

System.CodeDom.CodeTypeMemberCollection Member List:

Public Constructors
ctor #1 Overloaded:
.ctor()

Default constructor. This constructor is called by derived class constructors to initialize state in this type.
Initializes a new instance of the CodeTypeMemberCollection class.
ctor #2 Overloaded:
.ctor(CodeTypeMember[] value)

Initializes a new instance of the CodeTypeMemberCollection class containing the specified array of CodeTypeMember objects.
ctor #3 Overloaded:
.ctor(CodeTypeMemberCollection value)

Initializes a new instance of the CodeTypeMemberCollection class containing the elements of the specified source collection.
Public Properties
Count
(inherited from System.Collections.CollectionBase)
Read-only

See base class member description: System.Collections.CollectionBase.Count


Gets the number of elements contained in the CollectionBase instance.
Item Read-write

Gets or sets the CodeTypeMember at the specified index in the collection.
Public Methods
Add Adds a CodeTypeMember with the specified value to the collection.
AddRange Overloaded:
AddRange(CodeTypeMember[] value)

Copies the elements of the specified CodeTypeMember array to the end of the collection.
AddRange Overloaded:
AddRange(CodeTypeMemberCollection value)

Adds the contents of another CodeTypeMemberCollection to the end of the collection.
Clear
(inherited from System.Collections.CollectionBase)
See base class member description: System.Collections.CollectionBase.Clear


Removes all objects from the CollectionBase instance.
Contains Gets a value indicating whether the collection contains the specified CodeTypeMember.
CopyTo Copies the collection objects to a one-dimensional Array instance, beginning at the specified index.
Equals
(inherited from System.Object)
See base class member description: System.Object.Equals

Derived from System.Object, the primary base class for all objects.
GetEnumerator
(inherited from System.Collections.CollectionBase)
See base class member description: System.Collections.CollectionBase.GetEnumerator


Returns an enumerator that can iterate through the CollectionBase instance.
GetHashCode
(inherited from System.Object)
See base class member description: System.Object.GetHashCode

Derived from System.Object, the primary base class for all objects.
GetType
(inherited from System.Object)
See base class member description: System.Object.GetType

Derived from System.Object, the primary base class for all objects.
IndexOf Gets the index in the collection of the specified CodeTypeMember, if it exists in the collection.
Insert Inserts the specified CodeTypeMember into the collection at the specified index.
Remove Removes a specific CodeTypeMember from the collection.
RemoveAt
(inherited from System.Collections.CollectionBase)
See base class member description: System.Collections.CollectionBase.RemoveAt


Removes the element at the specified index of the CollectionBase instance.
ToString
(inherited from System.Object)
See base class member description: System.Object.ToString

Derived from System.Object, the primary base class for all objects.
Protected Properties
InnerList
(inherited from System.Collections.CollectionBase)
Read-only

See base class member description: System.Collections.CollectionBase.InnerList


Gets an ArrayList containing the list of elements in the CollectionBase instance.
List
(inherited from System.Collections.CollectionBase)
Read-only

See base class member description: System.Collections.CollectionBase.List


Gets an IList containing the list of elements in the CollectionBase instance.
Protected Methods
Finalize
(inherited from System.Object)
See base class member description: System.Object.Finalize

Derived from System.Object, the primary base class for all objects.
MemberwiseClone
(inherited from System.Object)
See base class member description: System.Object.MemberwiseClone

Derived from System.Object, the primary base class for all objects.
OnClear
(inherited from System.Collections.CollectionBase)
See base class member description: System.Collections.CollectionBase.OnClear


Performs additional custom processes when clearing the contents of the CollectionBase instance.
OnClearComplete
(inherited from System.Collections.CollectionBase)
See base class member description: System.Collections.CollectionBase.OnClearComplete


Performs additional custom processes after clearing the contents of the CollectionBase instance.
OnInsert
(inherited from System.Collections.CollectionBase)
See base class member description: System.Collections.CollectionBase.OnInsert


Performs additional custom processes before inserting a new element into the CollectionBase instance.
OnInsertComplete
(inherited from System.Collections.CollectionBase)
See base class member description: System.Collections.CollectionBase.OnInsertComplete


Performs additional custom processes after inserting a new element into the CollectionBase instance.
OnRemove
(inherited from System.Collections.CollectionBase)
See base class member description: System.Collections.CollectionBase.OnRemove


Performs additional custom processes when removing an element from the CollectionBase instance.
OnRemoveComplete
(inherited from System.Collections.CollectionBase)
See base class member description: System.Collections.CollectionBase.OnRemoveComplete


Performs additional custom processes after removing an element from the CollectionBase instance.
OnSet
(inherited from System.Collections.CollectionBase)
See base class member description: System.Collections.CollectionBase.OnSet


Performs additional custom processes before setting a value in the CollectionBase instance.
OnSetComplete
(inherited from System.Collections.CollectionBase)
See base class member description: System.Collections.CollectionBase.OnSetComplete


Performs additional custom processes after setting a value in the CollectionBase instance.
OnValidate
(inherited from System.Collections.CollectionBase)
See base class member description: System.Collections.CollectionBase.OnValidate


Performs additional custom processes when validating a value.

Hierarchy:


System.CodeDom.CodeTypeMemberCollection Member Details

Overloaded ctor #1
Summary
Initializes a new instance of the CodeTypeMemberCollection class.

Default constructor. This constructor is called by derived class constructors to initialize state in this type.
C# Syntax:
public CodeTypeMemberCollection();

Return to top


Overloaded ctor #2
Summary
Initializes a new instance of the CodeTypeMemberCollection class containing the specified array of CodeTypeMember objects.
C# Syntax:
public CodeTypeMemberCollection(
   CodeTypeMember[] value
);
Parameters:

value

An array of CodeTypeMember objects with which to intialize the collection.

Return to top


Overloaded ctor #3
Summary
Initializes a new instance of the CodeTypeMemberCollection class containing the elements of the specified source collection.
C# Syntax:
public CodeTypeMemberCollection(CodeTypeMemberCollection(
   CodeTypeMemberCollection value
);
Parameters:

value

A CodeTypeMemberCollection with which to initialize the collection.

Return to top


Property: Count (read-only)
Inherited
See base class member description: System.Collections.CollectionBase.Count

Summary
Gets the number of elements contained in the CollectionBase instance.
C# Syntax:
public int Count {get;}
Implements:
ICollection.Count

Return to top


Property: InnerList (read-only)
Inherited
See base class member description: System.Collections.CollectionBase.InnerList

Summary
Gets an ArrayList containing the list of elements in the CollectionBase instance.
C# Syntax:
protected ArrayList InnerList {get;}
Remarks
The On* methods are invoked only on the instance returned by the CollectionBase.List property, but not on the instance returned by the CollectionBase.InnerList property.

Return to top


Property: Item (read-write)
Summary
Gets or sets the CodeTypeMember at the specified index in the collection.
C# Syntax:
public CodeTypeMember this[int index] {get; set;}
Parameters:

index

The index of the collection to access. The index of the collection to access.

Exceptions
Exception Type Condition
ArgumentOutOfRangeException The index parameter is outside the valid range of indices for the collection.
Remarks
This method is an indexer that can be used to access the collection.

Return to top


Property: List (read-only)
Inherited
See base class member description: System.Collections.CollectionBase.List

Summary
Gets an IList containing the list of elements in the CollectionBase instance.
C# Syntax:
protected IList List {get;}
Remarks
The On* methods are invoked only on the instance returned by the CollectionBase.List property, but not on the instance returned by the CollectionBase.InnerList property.

Return to top


Method: Add(
   CodeTypeMember value
)
Summary
Adds a CodeTypeMember with the specified value to the collection.
C# Syntax:
public int Add(
   CodeTypeMember value
);
Parameters:

value

The CodeTypeMember to add.

Return Value:
The index at which the new element was inserted.
See also:
CodeTypeMemberCollection.AddRange

Return to top


Overloaded Method: AddRange(
   CodeTypeMember[] value
)
Summary
Copies the elements of the specified CodeTypeMember array to the end of the collection.
C# Syntax:
public void AddRange(
   CodeTypeMember[] value
);
Parameters:

value

An array of type CodeTypeMember containing the objects to add to the collection.

See also:
CodeTypeMemberCollection.Add

Return to top


Overloaded Method: AddRange(
   CodeTypeMemberCollection value
)
Summary
Adds the contents of another CodeTypeMemberCollection to the end of the collection.
C# Syntax:
public void AddRange(
   CodeTypeMemberCollection value
);
Parameters:

value

A CodeTypeMemberCollection containing the objects to add to the collection.

See also:
CodeTypeMemberCollection.Add

Return to top


Method: Clear()
Inherited
See base class member description: System.Collections.CollectionBase.Clear

Summary
Removes all objects from the CollectionBase instance.
C# Syntax:
public void Clear();
Implements:
IList.Clear
Remarks
CollectionBase.Count is set to zero.

Return to top


Method: Contains(
   CodeTypeMember value
)
Summary
Gets a value indicating whether the collection contains the specified CodeTypeMember.
C# Syntax:
public bool Contains(
   CodeTypeMember value
);
Parameters:

value

The CodeTypeMember to search for in the collection.

Return Value:
true if the collection contains the specified object; otherwise, false.
See also:
CodeTypeMemberCollection.IndexOf

Return to top


Method: CopyTo(
   CodeTypeMember[] array,
   int index
)
Summary
Copies the collection objects to a one-dimensional Array instance, beginning at the specified index.
C# Syntax:
public void CopyTo(
   CodeTypeMember[] array,
   int index
);
Parameters:

array

The one-dimensional Array that is the destination of the values copied from the collection. The one-dimensional Array that is the destination of the values copied from the collection.

index

The index of the array at which to begin inserting.

Exceptions
Exception Type Condition
ArgumentException The destination array is multidimensional.

-or-

The number of elements in the CodeTypeMemberCollection is greater than the available space between the index of the target array specified by the index parameter and the end of the target array.

ArgumentNullException The array parameter is null.
ArgumentOutOfRangeException The index parameter is less than the target array's minimum index.
See also:
Array

Return to top


Method: Equals(
   object obj
)
Inherited
See base class member description: System.Object.Equals
C# Syntax:
public virtual bool Equals(
   object obj
);

For more information on members inherited from System.Object click on the link above.

Return to top


Method: Finalize()
Inherited
See base class member description: System.Object.Finalize
C# Syntax:
~CodeTypeMemberCollection();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: GetEnumerator()
Inherited
See base class member description: System.Collections.CollectionBase.GetEnumerator

Summary
Returns an enumerator that can iterate through the CollectionBase instance.
C# Syntax:
public IEnumerator GetEnumerator();
Return Value:
An IEnumerator for the CollectionBase instance.
Implements:
IEnumerable.GetEnumerator
Remarks
Enumerators only allow reading the data in the collection. Enumerators cannot be used to modify the underlying collection.

Initially, the enumerator is positioned before the first element in the collection. IEnumerator.Reset also brings the enumerator back to this position. At this position, calling IEnumerator.Current throws an exception. Therefore, you must call IEnumerator.MoveNext to advance the enumerator to the first element of the collection before reading the value of IEnumerator.Current.

IEnumerator.Current returns the same object until either IEnumerator.MoveNext or IEnumerator.Reset is called. IEnumerator.MoveNext sets IEnumerator.Current to the next element.

After the end of the collection is passed, the enumerator is positioned after the last element in the collection, and calling IEnumerator.MoveNext returns false. If the last call to IEnumerator.MoveNext returned false, calling IEnumerator.Current throws an exception. To set IEnumerator.Current to the first element of the collection again, you can call IEnumerator.Reset followed by IEnumerator.MoveNext.

An enumerator remains valid as long as the collection remains unchanged. If changes are made to the collection, such as adding, modifying or deleting elements, the enumerator is irrecoverably invalidated and the next call to IEnumerator.MoveNext or IEnumerator.Reset throws an InvalidOperationException. If the collection is modified between IEnumerator.MoveNext and IEnumerator.Current, IEnumerator.Current will return the element that it is set to, even if the enumerator is already invalidated.

The enumerator does not have exclusive access to the collection; therefore, enumerating through a collection is intrinsically not a thread-safe procedure. Even when a collection is synchronized, other threads could still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads.

See also:
IEnumerator

Return to top


Method: GetHashCode()
Inherited
See base class member description: System.Object.GetHashCode
C# Syntax:
public virtual int GetHashCode();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: GetType()
Inherited
See base class member description: System.Object.GetType
C# Syntax:
public Type GetType();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: IndexOf(
   CodeTypeMember value
)
Summary
Gets the index in the collection of the specified CodeTypeMember, if it exists in the collection.
C# Syntax:
public int IndexOf(
   CodeTypeMember value
);
Parameters:

value

The CodeTypeMember to locate in the collection.

Return Value:
The index in the collection of the specified object, if found; otherwise, -1.
See also:
CodeTypeMemberCollection.Contains

Return to top


Method: Insert(
   int index,
   CodeTypeMember value
)
Summary
Inserts the specified CodeTypeMember into the collection at the specified index.
C# Syntax:
public void Insert(
   int index,
   CodeTypeMember value
);
Parameters:

index

The zero-based index where the specified object should be inserted.

value

The CodeTypeMember to insert.

See also:
CodeTypeMemberCollection.Add

Return to top


Method: MemberwiseClone()
Inherited
See base class member description: System.Object.MemberwiseClone
C# Syntax:
protected object MemberwiseClone();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: OnClear()
Inherited
See base class member description: System.Collections.CollectionBase.OnClear

Summary
Performs additional custom processes when clearing the contents of the CollectionBase instance.
C# Syntax:
protected virtual void OnClear();
Remarks
The default implementation of this method is intended to be overridden by a derived class to perform some action before the collection is cleared.

The On* methods are invoked only on the instance returned by the CollectionBase.List property, but not on the instance returned by the CollectionBase.InnerList property.



Notes to implementors:

This method allows implementers to define processes that must be performed before deleting all the elements from the underlying ArrayList. By defining this method, implementers can add functionality to inherited methods without having to override all other methods.

CollectionBase.OnClear is invoked before the standard Clear behavior, whereas CollectionBase.OnClearComplete is invoked after the standard Clear behavior.

For example, implementers can exempt certain elements from deletion by a global Clear.

See also:
CollectionBase.OnClearComplete | CollectionBase.OnRemove

Return to top


Method: OnClearComplete()
Inherited
See base class member description: System.Collections.CollectionBase.OnClearComplete

Summary
Performs additional custom processes after clearing the contents of the CollectionBase instance.
C# Syntax:
protected virtual void OnClearComplete();
Remarks
The default implementation of this method is intended to be overridden by a derived class to perform some action after the collection is cleared.

The On* methods are invoked only on the instance returned by the CollectionBase.List property, but not on the instance returned by the CollectionBase.InnerList property.



Notes to implementors:

This method allows implementers to define processes that must be performed after deleting all the elements from the underlying ArrayList. By defining this method, implementers can add functionality to inherited methods without having to override all other methods.

CollectionBase.OnClear is invoked before the standard Clear behavior, whereas CollectionBase.OnClearComplete is invoked after the standard Clear behavior.

See also:
CollectionBase.OnClear | CollectionBase.OnRemoveComplete

Return to top


Method: OnInsert(
   int index,
   object value
)
Inherited
See base class member description: System.Collections.CollectionBase.OnInsert

Summary
Performs additional custom processes before inserting a new element into the CollectionBase instance.
C# Syntax:
protected virtual void OnInsert(
   int index,
   object value
);
Parameters:

index

The zero-based index at which to insert value.

value

The new value of the element at index.

Remarks
The default implementation of this method is intended to be overridden by a derived class to perform some action before the specified element is inserted.

The On* methods are invoked only on the instance returned by the CollectionBase.List property, but not on the instance returned by the CollectionBase.InnerList property.



Notes to implementors:

This method allows implementers to define processes that must be performed before inserting the element into the underlying ArrayList. By defining this method, implementers can add functionality to inherited methods without having to override all other methods.

CollectionBase.OnInsert is invoked before the standard Insert behavior, whereas CollectionBase.OnInsertComplete is invoked after the standard Insert behavior.

For example, implementers can restrict which types of objects can be inserted into the ArrayList.

See also:
CollectionBase.OnInsertComplete | CollectionBase.OnSet | CollectionBase.OnValidate

Return to top


Method: OnInsertComplete(
   int index,
   object value
)
Inherited
See base class member description: System.Collections.CollectionBase.OnInsertComplete

Summary
Performs additional custom processes after inserting a new element into the CollectionBase instance.
C# Syntax:
protected virtual void OnInsertComplete(
   int index,
   object value
);
Parameters:

index

The zero-based index at which to insert value.

value

The new value of the element at index.

Remarks
The default implementation of this method is intended to be overridden by a derived class to perform some action after the specified element is inserted.

The On* methods are invoked only on the instance returned by the CollectionBase.List property, but not on the instance returned by the CollectionBase.InnerList property.



Notes to implementors:

This method allows implementers to define processes that must be performed after inserting the element into the underlying ArrayList. By defining this method, implementers can add functionality to inherited methods without having to override all other methods.

CollectionBase.OnInsert is invoked before the standard Insert behavior, whereas CollectionBase.OnInsertComplete is invoked after the standard Insert behavior.

See also:
CollectionBase.OnInsert | CollectionBase.OnSetComplete

Return to top


Method: OnRemove(
   int index,
   object value
)
Inherited
See base class member description: System.Collections.CollectionBase.OnRemove

Summary
Performs additional custom processes when removing an element from the CollectionBase instance.
C# Syntax:
protected virtual void OnRemove(
   int index,
   object value
);
Parameters:

index

The zero-based index at which value can be found.

value

The value of the element to remove from index.

Remarks
The default implementation of this method is intended to be overridden by a derived class to perform some action before the specified element is removed.

The On* methods are invoked only on the instance returned by the CollectionBase.List property, but not on the instance returned by the CollectionBase.InnerList property.



Notes to implementors:

This method allows implementers to define processes that must be performed before removing the element from the underlying ArrayList. By defining this method, implementers can add functionality to inherited methods without having to override all other methods.

CollectionBase.OnRemove is invoked before the standard Remove behavior, whereas CollectionBase.OnRemoveComplete is invoked after the standard Remove behavior.

For example, implementers can prevent removal of elements by always throwing an exception in CollectionBase.OnRemove.

See also:
CollectionBase.OnRemoveComplete | CollectionBase.OnClear

Return to top


Method: OnRemoveComplete(
   int index,
   object value
)
Inherited
See base class member description: System.Collections.CollectionBase.OnRemoveComplete

Summary
Performs additional custom processes after removing an element from the CollectionBase instance.
C# Syntax:
protected virtual void OnRemoveComplete(
   int index,
   object value
);
Parameters:

index

The zero-based index at which value can be found.

value

The value of the element to remove from index.

Remarks
The default implementation of this method is intended to be overridden by a derived class to perform some action after the specified element is removed.

The On* methods are invoked only on the instance returned by the CollectionBase.List property, but not on the instance returned by the CollectionBase.InnerList property.



Notes to implementors:

This method allows implementers to define processes that must be performed after removing the element from the underlying ArrayList. By defining this method, implementers can add functionality to inherited methods without having to override all other methods.

CollectionBase.OnRemove is invoked before the standard Remove behavior, whereas CollectionBase.OnRemoveComplete is invoked after the standard Remove behavior.

See also:
CollectionBase.OnRemove | CollectionBase.OnClearComplete

Return to top


Method: OnSet(
   int index,
   object oldValue,
   object newValue
)
Inherited
See base class member description: System.Collections.CollectionBase.OnSet

Summary
Performs additional custom processes before setting a value in the CollectionBase instance.
C# Syntax:
protected virtual void OnSet(
   int index,
   object oldValue,
   object newValue
);
Parameters:

index

The zero-based index at which oldValue can be found.

oldValue

The value to replace with newValue.

newValue

The new value of the element at index.

Remarks
The default implementation of this method is intended to be overridden by a derived class to perform some action before the specified element is set.

The On* methods are invoked only on the instance returned by the CollectionBase.List property, but not on the instance returned by the CollectionBase.InnerList property.



Notes to implementors:

This method allows implementers to define processes that must be performed before setting the specified element in the underlying ArrayList. By defining this method, implementers can add functionality to inherited methods without having to override all other methods.

CollectionBase.OnSet is invoked before the standard Set behavior, whereas CollectionBase.OnSetComplete is invoked after the standard Set behavior.

For example, implementers can restrict which values can be overwritten by performing a check inside CollectionBase.OnSet.

See also:
CollectionBase.OnSetComplete | CollectionBase.OnInsert | CollectionBase.OnValidate

Return to top


Method: OnSetComplete(
   int index,
   object oldValue,
   object newValue
)
Inherited
See base class member description: System.Collections.CollectionBase.OnSetComplete

Summary
Performs additional custom processes after setting a value in the CollectionBase instance.
C# Syntax:
protected virtual void OnSetComplete(
   int index,
   object oldValue,
   object newValue
);
Parameters:

index

The zero-based index at which oldValue can be found.

oldValue

The value to replace with newValue.

newValue

The new value of the element at index.

Remarks
The default implementation of this method is intended to be overridden by a derived class to perform some action after the specified element is set.

The On* methods are invoked only on the instance returned by the CollectionBase.List property, but not on the instance returned by the CollectionBase.InnerList property.



Notes to implementors:

This method allows implementers to define processes that must be performed after setting the specified element in the underlying ArrayList. By defining this method, implementers can add functionality to inherited methods without having to override all other methods.

CollectionBase.OnSet is invoked before the standard Set behavior, whereas CollectionBase.OnSetComplete is invoked after the standard Set behavior.

See also:
CollectionBase.OnSet | CollectionBase.OnInsertComplete

Return to top


Method: OnValidate(
   object value
)
Inherited
See base class member description: System.Collections.CollectionBase.OnValidate

Summary
Performs additional custom processes when validating a value.
C# Syntax:
protected virtual void OnValidate(
   object value
);
Parameters:

value

The object to validate.

Remarks
The default implementation of this method determines whether value is null, and, if so, throws ArgumentNullException. It is intended to be overridden by a derived class to perform additional action when the specified element is validated.

The On* methods are invoked only on the instance returned by the CollectionBase.List property, but not on the instance returned by the CollectionBase.InnerList property.



Notes to implementors:

This method allows implementers to define processes that must be performed when executing the standard behavior of the underlying ArrayList. By defining this method, implementers can add functionality to inherited methods without having to override all other methods.

CollectionBase.OnValidate can be used to impose restrictions on the type of objects that are accepted into the collection. The default implementation prevents null from being added to or removed from the underlying ArrayList.

See also:
CollectionBase.OnSet | CollectionBase.OnInsert

Return to top


Method: Remove(
   CodeTypeMember value
)
Summary
Removes a specific CodeTypeMember from the collection.
C# Syntax:
public void Remove(
   CodeTypeMember value
);
Parameters:

value

The CodeTypeMember to remove from the collection. The CodeTypeMember to remove from the collection.

Exceptions
Exception Type Condition
ArgumentException The specified object is not found in the collection.

Return to top


Method: RemoveAt(
   int index
)
Inherited
See base class member description: System.Collections.CollectionBase.RemoveAt

Summary
Removes the element at the specified index of the CollectionBase instance.
C# Syntax:
public void RemoveAt(
   int index
);
Parameters:

index

The zero-based index of the element to remove.

Exceptions
Exception Type Condition
ArgumentOutOfRangeException index is less than zero.

-or-

index is equal to or greater than CollectionBase.Count.

Implements:
IList.RemoveAt
Remarks
In collections of contiguous elements, such as lists, the elements that follow the removed element move up to occupy the vacated spot. If the collection is indexed, the indexes of the elements that are moved are also updated. This behavior does not apply to collections where elements are conceptually grouped into buckets, such as a hashtable.

Return to top


Method: ToString()
Inherited
See base class member description: System.Object.ToString
C# Syntax:
public virtual string ToString();

For more information on members inherited from System.Object click on the link above.

Return to top


Top of page

Copyright (c) 2002 Microsoft Corporation. All rights reserved.