CodeDirectiveCollection.Contains(CodeDirective) Metod
Definition
Viktigt
En del information gäller för förhandsversionen av en produkt och kan komma att ändras avsevärt innan produkten blir allmänt tillgänglig. Microsoft lämnar inga garantier, uttryckliga eller underförstådda, avseende informationen som visas här.
Hämtar ett värde som anger om samlingen innehåller det angivna CodeDirective objektet.
public:
bool Contains(System::CodeDom::CodeDirective ^ value);
public bool Contains(System.CodeDom.CodeDirective value);
member this.Contains : System.CodeDom.CodeDirective -> bool
Public Function Contains (value As CodeDirective) As Boolean
Parametrar
- value
- CodeDirective
Objektet CodeDirective som ska sökas efter i samlingen.
Returer
trueom samlingen innehåller det angivna objektet; annars . false
Exempel
I följande kodexempel visas hur metoden används Contains för att avgöra om samlingen innehåller ett specifikt CodeDirective objekt. Det här exemplet är en del av ett större exempel som tillhandahålls CodeDirectiveCollection för klassen.
// Tests for the presence of a CodeDirective in the
// collection, and retrieves its index if it is found.
CodeDirective testDirective = new CodeRegionDirective(CodeRegionMode.Start, "Region1");
int itemIndex = -1;
if (collection.Contains(testDirective))
itemIndex = collection.IndexOf(testDirective);
' Tests for the presence of a CodeDirective in the
' collection, and retrieves its index if it is found.
Dim testDirective = New CodeRegionDirective(CodeRegionMode.Start, "Region1")
Dim itemIndex As Integer = -1
If collection.Contains(testDirective) Then
itemIndex = collection.IndexOf(testDirective)
End If