PerformanceCounterCategory.CategoryName Properti
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
Mendapatkan atau mengatur nama objek performa yang menentukan kategori ini.
public:
property System::String ^ CategoryName { System::String ^ get(); void set(System::String ^ value); };
public string CategoryName { get; set; }
member this.CategoryName : string with get, set
Public Property CategoryName As String
Nilai Properti
Nama kategori penghitung kinerja, atau objek performa, untuk mengaitkan instans ini PerformanceCounterCategory .
Pengecualian
CategoryName adalah string kosong ("").
CategoryName adalah null
.
Contoh
Contoh kode berikut membuat PerformanceCounterCategory dengan PerformanceCounterCategory(). Ini meminta pengguna untuk PerformanceCounterCategory nama komputer dan , lalu mengatur CategoryName properti dan MachineName dari nilai yang dimasukkan. Kemudian menampilkan nilai CategoryNameproperti , , MachineNamedan CategoryHelp , atau menampilkan pesan kesalahan jika PerformanceCounterCategory tidak dapat diakses.
public static void Main(string[] args)
{
string categoryName = "";
string machineName = "";
PerformanceCounterCategory pcc = new PerformanceCounterCategory();
// Prompt for fields and set the corresponding properties.
while (categoryName.Length==0)
{
Console.Write("Please enter a non-blank category name: ");
categoryName = Console.ReadLine().Trim();
if (categoryName.Length>0)
{
pcc.CategoryName = categoryName;
}
}
while (machineName.Length==0)
{
Console.Write("Enter a non-blank computer name ['.' for local]: ");
machineName = Console.ReadLine().Trim();
if (machineName.Length>0)
{
pcc.MachineName = machineName;
}
}
// Display the properties of the PerformanceCounterCategory object.
try
{
Console.WriteLine(" Category: {0}", pcc.CategoryName);
Console.WriteLine(" Computer: {0}", pcc.MachineName);
Console.WriteLine(" Help text: {0}", pcc.CategoryHelp);
}
catch(Exception ex)
{
Console.WriteLine("Error getting the properties of the " +
"PerformanceCounterCategory object:");
Console.WriteLine(ex.Message);
}
}
Sub Main(ByVal args() As String)
Dim categoryName As String = ""
Dim machineName As String = ""
Dim pcc As New PerformanceCounterCategory
' Prompt for fields and set the corresponding properties.
While categoryName.Length = 0
Console.Write("Please enter a non-blank category name: ")
categoryName = Console.ReadLine().Trim
If categoryName.Length > 0 Then
pcc.CategoryName = categoryName
End If
End While
While machineName.Length = 0
Console.Write( _
"Enter a non-blank computer name ['.' for local]: ")
machineName = Console.ReadLine().Trim
If machineName.Length > 0 Then
pcc.MachineName = machineName
End If
End While
' Display the properties of the PerformanceCounterCategory object.
Try
Console.WriteLine(" Category: {0}", pcc.CategoryName)
Console.WriteLine(" Computer: {0}", pcc.MachineName)
Console.WriteLine(" Help text: {0}", pcc.CategoryHelp)
Catch ex As Exception
Console.WriteLine("Error getting the properties of the " & _
"PerformanceCounterCategory object:")
Console.WriteLine(ex.Message)
End Try
End Sub