InstanceDataCollectionCollection::Contains Method (String^)

 

Determines whether an instance data collection for the specified counter (identified by one of the indexed InstanceDataCollection objects) exists in the collection.

Namespace:   System.Diagnostics
Assembly:  System (in System.dll)

public:
bool Contains(
	String^ counterName
)

Parameters

counterName
Type: System::String^

The name of the performance counter.

Return Value

Type: System::Boolean

true if an instance data collection containing the specified counter exists in the collection; otherwise, false.

Exception Condition
ArgumentNullException

The counterName parameter is null.

The counterName parameter is case-insensitive.

Each InstanceDataCollection object in the collection contains the performance data for all counters for an instance. The data is indexed by counter name and then by instance name. Contains returns true if there is an InstanceDataCollection object whose associated counter has the name specified by the counterName parameter.

The following code example accepts a PerformanceCounter category name and counter name from the command line. It gets the InstanceDataCollectionCollection for the PerformanceCounterCategory and then uses the Contains method to determine if the specified counter exists. If the counter exists, the example gets the associated InstanceDataCollection and displays the instance names from the collection.

No code example is currently available or this language may not be supported.

.NET Framework
Available since 1.1
Return to top
Show: