Redigera

CodeTypeReferenceCollection Class

Definition

Represents a collection of CodeTypeReference objects.

public ref class CodeTypeReferenceCollection : System::Collections::CollectionBase
public class CodeTypeReferenceCollection : System.Collections.CollectionBase
type CodeTypeReferenceCollection = class
    inherit CollectionBase
Public Class CodeTypeReferenceCollection
Inherits CollectionBase
Inheritance
CodeTypeReferenceCollection

Examples

// Creates an empty CodeTypeReferenceCollection.
CodeTypeReferenceCollection collection = new CodeTypeReferenceCollection();

// Adds a CodeTypeReference to the collection.
collection.Add( new CodeTypeReference(typeof(bool)) );

// Adds an array of CodeTypeReference objects to the collection.
CodeTypeReference[] references = { new CodeTypeReference(typeof(bool)), new CodeTypeReference(typeof(bool)) };
collection.AddRange( references );

// Adds a collection of CodeTypeReference objects to the collection.
CodeTypeReferenceCollection referencesCollection = new CodeTypeReferenceCollection();
referencesCollection.Add( new CodeTypeReference(typeof(bool)) );
referencesCollection.Add( new CodeTypeReference(typeof(bool)) );
collection.AddRange( referencesCollection );

// Tests for the presence of a CodeTypeReference in the
// collection, and retrieves its index if it is found.
CodeTypeReference testReference = new CodeTypeReference(typeof(bool));
int itemIndex = -1;
if( collection.Contains( testReference ) )
    itemIndex = collection.IndexOf( testReference );

// Copies the contents of the collection, beginning at index 0,
// to the specified CodeTypeReference array.
// 'references' is a CodeTypeReference array.
collection.CopyTo( references, 0 );

// Retrieves the count of the items in the collection.
int collectionCount = collection.Count;

// Inserts a CodeTypeReference at index 0 of the collection.
collection.Insert( 0, new CodeTypeReference(typeof(bool)) );

// Removes the specified CodeTypeReference from the collection.
CodeTypeReference reference = new CodeTypeReference(typeof(bool));
collection.Remove( reference );

// Removes the CodeTypeReference at index 0.
collection.RemoveAt(0);
' Creates an empty CodeTypeReferenceCollection.
Dim collection As New CodeTypeReferenceCollection()

' Adds a CodeTypeReference to the collection.
collection.Add(New CodeTypeReference(GetType(Boolean)))

' Adds an array of CodeTypeReference objects to the collection.
Dim references As CodeTypeReference() = {New CodeTypeReference(GetType(Boolean)), New CodeTypeReference(GetType(Boolean))}
collection.AddRange(references)

' Adds a collection of CodeTypeReference objects to the collection.
Dim referencesCollection As New CodeTypeReferenceCollection()
referencesCollection.Add(New CodeTypeReference(GetType(Boolean)))
referencesCollection.Add(New CodeTypeReference(GetType(Boolean)))
collection.AddRange(referencesCollection)

' Tests for the presence of a CodeTypeReference in the 
' collection, and retrieves its index if it is found.
Dim testReference As New CodeTypeReference(GetType(Boolean))
Dim itemIndex As Integer = -1
If collection.Contains(testReference) Then
    itemIndex = collection.IndexOf(testReference)
End If

' Copies the contents of the collection, beginning at index 0, 
' to the specified CodeTypeReference array.
' 'references' is a CodeTypeReference array.
collection.CopyTo(references, 0)

' Retrieves the count of the items in the collection.
Dim collectionCount As Integer = collection.Count

' Inserts a CodeTypeReference at index 0 of the collection.
collection.Insert(0, New CodeTypeReference(GetType(Boolean)))

' Removes the specified CodeTypeReference from the collection.
Dim reference As New CodeTypeReference(GetType(Boolean))
collection.Remove(reference)

' Removes the CodeTypeReference at index 0.
collection.RemoveAt(0)

Remarks

The CodeTypeReferenceCollection class provides a simple collection object that can be used to store a set of CodeTypeReference objects.

Constructors

Name Description
CodeTypeReferenceCollection()

Initializes a new instance of the CodeTypeReferenceCollection class.

CodeTypeReferenceCollection(CodeTypeReference[])

Initializes a new instance of the CodeTypeReferenceCollection class containing the specified array of CodeTypeReference objects.

CodeTypeReferenceCollection(CodeTypeReferenceCollection)

Initializes a new instance of the CodeTypeReferenceCollection class containing the elements of the specified source collection.

Properties

Name Description
Item[Int32]

Gets or sets the CodeTypeReference at the specified index in the collection.

Methods

Name Description
Add(CodeTypeReference)

Adds the specified CodeTypeReference to the collection.

Add(String)

Adds a CodeTypeReference to the collection using the specified data type name.

Add(Type)

Adds a CodeTypeReference to the collection using the specified data type.

AddRange(CodeTypeReference[])

Copies the elements of the specified CodeTypeReference array to the end of the collection.

AddRange(CodeTypeReferenceCollection)

Adds the contents of the specified CodeTypeReferenceCollection to the end of the collection.

Contains(CodeTypeReference)

Gets a value indicating whether the collection contains the specified CodeTypeReference.

CopyTo(CodeTypeReference[], Int32)

Copies the items in the collection to the specified one-dimensional Array at the specified index.

IndexOf(CodeTypeReference)

Gets the index in the collection of the specified CodeTypeReference, if it exists in the collection.

Insert(Int32, CodeTypeReference)

Inserts a CodeTypeReference into the collection at the specified index.

Remove(CodeTypeReference)

Removes the specified CodeTypeReference from the collection.

Applies to

See also