Freigeben über


CompilerErrorCollection-Klasse

Stellt eine Auflistung von CompilerError-Objekten dar.

Namespace: System.CodeDom.Compiler
Assembly: System (in system.dll)

Syntax

'Declaration
<SerializableAttribute> _
Public Class CompilerErrorCollection
    Inherits CollectionBase
'Usage
Dim instance As CompilerErrorCollection
[SerializableAttribute] 
public class CompilerErrorCollection : CollectionBase
[SerializableAttribute] 
public ref class CompilerErrorCollection : public CollectionBase
/** @attribute SerializableAttribute() */ 
public class CompilerErrorCollection extends CollectionBase
SerializableAttribute 
public class CompilerErrorCollection extends CollectionBase

Hinweise

Die CompilerErrorCollection-Klasse stellt ein einfaches Auflistungsobjekt bereit, das zum Speichern einer Gruppe von CompilerError-Objekten verwendet werden kann.

Hinweis

Diese Klasse enthält eine Vererbungsanforderung auf der Klassenebene, die auf alle Member angewendet wird. Wenn die abgeleitete Klasse keine Berechtigung mit voller Vertrauenswürdigkeit besitzt, wird eine SecurityException-Ausnahme ausgelöst. Details zu Vererbungsanforderungen finden Sie unter Vererbungsforderungen.

Beispiel

' Creates an empty CompilerErrorCollection.
Dim collection As New CompilerErrorCollection()

' Adds a CompilerError to the collection.
collection.Add(New CompilerError("Testfile.cs", 5, 10, "CS0001", "Example error text"))

' Adds an array of CompilerError objects to the collection.
Dim errors As CompilerError() = {New CompilerError("Testfile.cs", 5, 10, "CS0001", "Example error text"), New CompilerError("Testfile.cs", 5, 10, "CS0001", "Example error text")}
collection.AddRange(errors)

' Adds a collection of CompilerError objects to the collection.
Dim errorsCollection As New CompilerErrorCollection()
errorsCollection.Add(New CompilerError("Testfile.cs", 5, 10, "CS0001", "Example error text"))
errorsCollection.Add(New CompilerError("Testfile.cs", 5, 10, "CS0001", "Example error text"))
collection.AddRange(errorsCollection)

' Tests for the presence of a CompilerError in the 
' collection, and retrieves its index if it is found.
Dim testError As New CompilerError("Testfile.cs", 5, 10, "CS0001", "Example error text")
Dim itemIndex As Integer = -1
If collection.Contains(testError) Then
    itemIndex = collection.IndexOf(testError)
End If

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

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

' Inserts a CompilerError at index 0 of the collection.
collection.Insert(0, New CompilerError("Testfile.cs", 5, 10, "CS0001", "Example error text"))

' Removes the specified CompilerError from the collection.
Dim [error] As New CompilerError("Testfile.cs", 5, 10, "CS0001", "Example error text")
collection.Remove([error])

' Removes the CompilerError at index 0.
collection.RemoveAt(0)
// Creates an empty CompilerErrorCollection.
CompilerErrorCollection collection = new CompilerErrorCollection();                        

// Adds a CompilerError to the collection.
collection.Add( new CompilerError("Testfile.cs", 5, 10, "CS0001", "Example error text") );

// Adds an array of CompilerError objects to the collection.
CompilerError[] errors = { new CompilerError("Testfile.cs", 5, 10, "CS0001", "Example error text"), new CompilerError("Testfile.cs", 5, 10, "CS0001", "Example error text") };
collection.AddRange( errors );

// Adds a collection of CompilerError objects to the collection.
CompilerErrorCollection errorsCollection = new CompilerErrorCollection();
errorsCollection.Add( new CompilerError("Testfile.cs", 5, 10, "CS0001", "Example error text") );
errorsCollection.Add( new CompilerError("Testfile.cs", 5, 10, "CS0001", "Example error text") );
collection.AddRange( errorsCollection );

// Tests for the presence of a CompilerError in the 
// collection, and retrieves its index if it is found.
CompilerError testError = new CompilerError("Testfile.cs", 5, 10, "CS0001", "Example error text");
int itemIndex = -1;
if( collection.Contains( testError ) )
    itemIndex = collection.IndexOf( testError );

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

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

// Inserts a CompilerError at index 0 of the collection.
collection.Insert( 0, new CompilerError("Testfile.cs", 5, 10, "CS0001", "Example error text") );

// Removes the specified CompilerError from the collection.
CompilerError error = new CompilerError("Testfile.cs", 5, 10, "CS0001", "Example error text");
collection.Remove( error );

// Removes the CompilerError at index 0.
collection.RemoveAt(0);
// Creates an empty CompilerErrorCollection.
CompilerErrorCollection^ collection = gcnew CompilerErrorCollection;

// Adds a CompilerError to the collection.
collection->Add( gcnew CompilerError( "Testfile::cs",5,10,"CS0001","Example error text" ) );

// Adds an array of CompilerError objects to the collection.
array<CompilerError^>^errors = {gcnew CompilerError( "Testfile.cs",5,10,"CS0001","Example error text" ),gcnew CompilerError( "Testfile::cs",5,10,"CS0001","Example error text" )};
collection->AddRange( errors );

// Adds a collection of CompilerError objects to the collection.
CompilerErrorCollection^ errorsCollection = gcnew CompilerErrorCollection;
errorsCollection->Add( gcnew CompilerError( "Testfile.cs",5,10,"CS0001","Example error text" ) );
errorsCollection->Add( gcnew CompilerError( "Testfile.cs",5,10,"CS0001","Example error text" ) );
collection->AddRange( errorsCollection );

// Tests for the presence of a CompilerError in the
// collection, and retrieves its index if it is found.
CompilerError^ testError = gcnew CompilerError( "Testfile.cs",5,10,"CS0001","Example error text" );
int itemIndex = -1;
if ( collection->Contains( testError ) )
   itemIndex = collection->IndexOf( testError );

// Copies the contents of the collection, beginning at index 0,
// to the specified CompilerError array.
// 'errors' is a CompilerError array.
collection->CopyTo( errors, 0 );

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

// Inserts a CompilerError at index 0 of the collection.
collection->Insert( 0, gcnew CompilerError( "Testfile.cs",5,10,"CS0001","Example error text" ) );

// Removes the specified CompilerError from the collection.
CompilerError^ error = gcnew CompilerError( "Testfile.cs",5,10,"CS0001","Example error text" );
collection->Remove( error );

// Removes the CompilerError at index 0.
collection->RemoveAt( 0 );
// Creates an empty CompilerErrorCollection.
CompilerErrorCollection collection = new CompilerErrorCollection();

// Adds a CompilerError to the collection.
collection.Add(new CompilerError("Testfile.cs", 5, 10, "CS0001", 
    "Example error text"));

// Adds an array of CompilerError objects to the collection.
CompilerError errors[] =  { new CompilerError("Testfile.cs", 5, 10, 
    "CS0001", "Example error text"), new CompilerError("Testfile.jsl", 5,
    10, "CS0001", "Example error text") };
collection.AddRange(errors);
// Adds a collection of CompilerError objects to the collection.
CompilerErrorCollection errorsCollection = new CompilerErrorCollection();
errorsCollection.Add(new CompilerError("Testfile.jsl", 5, 10, "CS0001",
    "Example error text"));
errorsCollection.Add(new CompilerError("Testfile.jsl", 5, 10, "JSL0001",
    "Example error text"));
collection.AddRange(errorsCollection);

// Tests for the presence of a CompilerError in the 
// collection, and retrieves its index if it is found.
CompilerError testError = new CompilerError("Testfile.JSL", 5, 10,
    "JSL0001", "Example error text");
int itemIndex = -1;
if (collection.Contains(testError)) {
    itemIndex = collection.IndexOf(testError);
}

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

// Retrieves the count of the items in the collection.
int collectionCount = collection.get_Count();

// Inserts a CompilerError at index 0 of the collection.
collection.Insert(0, new CompilerError("Testfile.cs", 5, 10, "JSL0001",
    "Example error text"));

// Removes the specified CompilerError from the collection.
CompilerError error = new CompilerError("Testfile.cs", 5, 10, "JSL0001",
    "Example error text");
collection.Remove(error);

// Removes the CompilerError at index 0.
collection.RemoveAt(0);

.NET Framework-Sicherheit

Vererbungshierarchie

System.Object
   System.Collections.CollectionBase
    System.CodeDom.Compiler.CompilerErrorCollection

Threadsicherheit

Alle öffentlichen statischen (Shared in Visual Basic) Member dieses Typs sind threadsicher. Bei Instanzmembern ist die Threadsicherheit nicht gewährleistet.

Plattformen

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

Siehe auch

Referenz

CompilerErrorCollection-Member
System.CodeDom.Compiler-Namespace
CompilerErrorCollection-Klasse