次の方法で共有


CompilerErrorCollection クラス

CompilerError オブジェクトのコレクションを表します。

この型のすべてのメンバの一覧については、CompilerErrorCollection メンバ を参照してください。

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

<Serializable>
Public Class CompilerErrorCollection   Inherits CollectionBase
[C#]
[Serializable]
public class CompilerErrorCollection : CollectionBase
[C++]
[Serializable]
public __gc class CompilerErrorCollection : public CollectionBase
[JScript]
public
   Serializable
class CompilerErrorCollection extends CollectionBase

スレッドセーフ

この型の public static (Visual Basicでは Shared) のすべてのメンバは、マルチスレッド操作で安全に使用できます。インスタンスのメンバの場合は、スレッドセーフであるとは限りません。

解説

CompilerErrorCollection クラスは、 CompilerError オブジェクトのセットを格納するために使用できる単純なコレクション オブジェクトを提供します。

使用例

 
' 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)

[C#] 
// 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);

[C++] 
// Creates an empty CompilerErrorCollection.
CompilerErrorCollection* collection = new CompilerErrorCollection();

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

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

// Adds a collection of CompilerError objects to the collection.
CompilerErrorCollection* errorsCollection = new CompilerErrorCollection();
errorsCollection->Add(new CompilerError(S"Testfile.cs", 5, 10, S"CS0001", S"Example error text"));
errorsCollection->Add(new CompilerError(S"Testfile.cs", 5, 10, S"CS0001", S"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(S"Testfile.cs", 5, 10, S"CS0001", S"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(S"Testfile.cs", 5, 10, S"CS0001", S"Example error text"));

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

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

[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

名前空間: System.CodeDom.Compiler

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ

アセンブリ: System (System.dll 内)

参照

CompilerErrorCollection メンバ | System.CodeDom.Compiler 名前空間 | CompilerErrorCollection