CodeTypeMemberCollection クラス
CodeTypeMember オブジェクトのコレクションを表します。
この型のすべてのメンバの一覧については、CodeTypeMemberCollection メンバ を参照してください。
System.Object
System.Collections.CollectionBase
System.CodeDom.CodeTypeMemberCollection
<Serializable>
<ClassInterface(ClassInterfaceType.AutoDispatch)>
<ComVisible(True)>
Public Class CodeTypeMemberCollection Inherits CollectionBase
[C#]
[Serializable]
[ClassInterface(ClassInterfaceType.AutoDispatch)]
[ComVisible(true)]
public class CodeTypeMemberCollection : CollectionBase
[C++]
[Serializable]
[ClassInterface(ClassInterfaceType::AutoDispatch)]
[ComVisible(true)]
public __gc class CodeTypeMemberCollection : public CollectionBase
[JScript]
public
Serializable
ClassInterface(ClassInterfaceType.AutoDispatch)
ComVisible(true)
class CodeTypeMemberCollection extends CollectionBase
スレッドセーフ
この型の public static (Visual Basicでは Shared) のすべてのメンバは、マルチスレッド操作で安全に使用できます。インスタンスのメンバの場合は、スレッドセーフであるとは限りません。
解説
CodeTypeMemberCollection クラスは、 CodeTypeMember オブジェクトのセットを格納するために使用できる単純なコレクション オブジェクトを提供します。
使用例
' Creates an empty CodeTypeMemberCollection.
Dim collection As New CodeTypeMemberCollection()
' Adds a CodeTypeMember to the collection.
collection.Add(New CodeMemberField("System.String", "TestStringField"))
' Adds an array of CodeTypeMember objects to the collection.
Dim members As CodeTypeMember() = {New CodeMemberField("System.String", "TestStringField1"), New CodeMemberField("System.String", "TestStringField2")}
collection.AddRange(members)
' Adds a collection of CodeTypeMember objects to the collection.
Dim membersCollection As New CodeTypeMemberCollection()
membersCollection.Add(New CodeMemberField("System.String", "TestStringField1"))
membersCollection.Add(New CodeMemberField("System.String", "TestStringField2"))
collection.AddRange(membersCollection)
' Tests for the presence of a CodeTypeMember within the collection, and retrieves its index if it is within the collection.
Dim testMember = New CodeMemberField("System.String", "TestStringField")
Dim itemIndex As Integer = -1
If collection.Contains(testMember) Then
itemIndex = collection.IndexOf(testMember)
End If
' Copies the contents of the collection, beginning at index 0,
' to the specified CodeTypeMember array.
' 'members' is a CodeTypeMember array.
collection.CopyTo(members, 0)
' Retrieves the count of the items in the collection.
Dim collectionCount As Integer = collection.Count
' Inserts a CodeTypeMember at index 0 of the collection.
collection.Insert(0, New CodeMemberField("System.String", "TestStringField"))
' Removes the specified CodeTypeMember from the collection.
Dim member = New CodeMemberField("System.String", "TestStringField")
collection.Remove(member)
' Removes the CodeTypeMember at index 0.
collection.RemoveAt(0)
[C#]
// Creates an empty CodeTypeMemberCollection.
CodeTypeMemberCollection collection = new CodeTypeMemberCollection();
// Adds a CodeTypeMember to the collection.
collection.Add( new CodeMemberField("System.String", "TestStringField") );
// Adds an array of CodeTypeMember objects to the collection.
CodeTypeMember[] members = { new CodeMemberField("System.String", "TestStringField1"), new CodeMemberField("System.String", "TestStringField2") };
collection.AddRange( members );
// Adds a collection of CodeTypeMember objects to the collection.
CodeTypeMemberCollection membersCollection = new CodeTypeMemberCollection();
membersCollection.Add( new CodeMemberField("System.String", "TestStringField1") );
membersCollection.Add( new CodeMemberField("System.String", "TestStringField2") );
collection.AddRange( membersCollection );
// Tests for the presence of a CodeTypeMember in the collection,
// and retrieves its index if it is found.
CodeTypeMember testMember = new CodeMemberField("System.String", "TestStringField");
int itemIndex = -1;
if( collection.Contains( testMember ) )
itemIndex = collection.IndexOf( testMember );
// Copies the contents of the collection, beginning at index 0,
// to the specified CodeTypeMember array.
// 'members' is a CodeTypeMember array.
collection.CopyTo( members, 0 );
// Retrieves the count of the items in the collection.
int collectionCount = collection.Count;
// Inserts a CodeTypeMember at index 0 of the collection.
collection.Insert( 0, new CodeMemberField("System.String", "TestStringField") );
// Removes the specified CodeTypeMember from the collection.
CodeTypeMember member = new CodeMemberField("System.String", "TestStringField");
collection.Remove( member );
// Removes the CodeTypeMember at index 0.
collection.RemoveAt(0);
[C++]
// Creates an empty CodeTypeMemberCollection.
CodeTypeMemberCollection* collection = new CodeTypeMemberCollection();
// Adds a CodeTypeMember to the collection.
collection->Add( new CodeMemberField(S"System.String", S"TestStringField") );
// Adds an array of CodeTypeMember objects to the collection.
CodeTypeMember* members[] = { new CodeMemberField(S"System.String", S"TestStringField1"), new CodeMemberField(S"System.String", S"TestStringField2") };
collection->AddRange( members );
// Adds a collection of CodeTypeMember objects to the collection.
CodeTypeMemberCollection* membersCollection = new CodeTypeMemberCollection();
membersCollection->Add( new CodeMemberField(S"System.String", S"TestStringField1") );
membersCollection->Add( new CodeMemberField(S"System.String", S"TestStringField2") );
collection->AddRange( membersCollection );
// Tests for the presence of a CodeTypeMember in the collection,
// and retrieves its index if it is found.
CodeTypeMember* testMember = new CodeMemberField(S"System.String", S"TestStringField");
int itemIndex = -1;
if( collection->Contains( testMember ) )
itemIndex = collection->IndexOf( testMember );
// Copies the contents of the collection, beginning at index 0,
// to the specified CodeTypeMember array.
// 'members' is a CodeTypeMember array.
collection->CopyTo( members, 0 );
// Retrieves the count of the items in the collection.
int collectionCount = collection->Count;
// Inserts a CodeTypeMember at index 0 of the collection.
collection->Insert( 0, new CodeMemberField(S"System.String", S"TestStringField") );
// Removes the specified CodeTypeMember from the collection.
CodeTypeMember* member = new CodeMemberField(S"System.String", S"TestStringField");
collection->Remove( member );
// Removes the CodeTypeMember at index 0.
collection->RemoveAt(0);
[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
必要条件
名前空間: System.CodeDom
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ
アセンブリ: System (System.dll 内)
参照
CodeTypeMemberCollection メンバ | System.CodeDom 名前空間 | CodeTypeMember