CompilerErrorCollection (Clase)
Ensamblado: System (en system.dll)
La clase CompilerErrorCollection proporciona un objeto de colección simple que se puede utilizar para almacenar un conjunto de objetos CompilerError.
Nota |
|---|
| Esta clase contiene una petición de herencia en el nivel de clase que se aplica a todos los miembros. Se produce una excepción SecurityException si la clase derivada no dispone de permisos de plena confianza. Para obtener más información sobre las peticiones de herencia, vea Peticiones de herencia. |
// 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 = 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);
- SecurityPermission para derivar de la clase CompilerErrorCollection. Valor de la petición: InheritanceDemand; Conjuntos de permisos con nombre: FullTrust.
Windows 98, Windows 2000 SP4, Windows Millennium, Windows Server 2003, Windows XP Media Center, Windows XP Professional x64, Windows XP SP2, Windows XP Starter Edition
.NET Framework no admite todas las versiones de cada plataforma. Para obtener una lista de las versiones admitidas, vea Requisitos del sistema.
Nota