This documentation is archived and is not being maintained.

PerformanceCounter.CounterName Property

Gets or sets the name of the performance counter that is associated with this PerformanceCounter instance.

[Visual Basic]
Public Property CounterName As String
[C#]
public string CounterName {get; set;}
[C++]
public: __property String* get_CounterName();
public: __property void set_CounterName(String*);
[JScript]
public function get CounterName() : String;
public function set CounterName(String);

Property Value

The name of the counter, which generally describes the quantity being counted. This name is displayed in the list of counters of the Performance Counter Manager MMC snap in's Add Countersdialog box.

Exceptions

Exception Type Condition
ArgumentNullException The CounterName is a null reference (Nothing in Visual Basic).

Example

[Visual Basic] 
Dim PC As New PerformanceCounter()
PC.CategoryName = "Process"
PC.CounterName = "Private Bytes"
PC.InstanceName = "Explorer"
MessageBox.Show(PC.NextValue().ToString())

[C#] 
PerformanceCounter PC=new PerformanceCounter();
PC.CategoryName="Process";
PC.CounterName="Private Bytes";
PC.InstanceName="Explorer";
MessageBox.Show(PC.NextValue().ToString());

[C++] 
PerformanceCounter* PC = new PerformanceCounter();
PC->CategoryName=S"Process";
PC->CounterName=S"Private Bytes";
PC->InstanceName=S"Explorer";
MessageBox::Show(PC->NextValue().ToString());

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows NT Server 4.0, Windows NT Workstation 4.0, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

PerformanceCounter Class | PerformanceCounter Members | System.Diagnostics Namespace

Show: