PerformanceCounterCategory Konstruktor
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.
Menginisialisasi instans baru kelas PerformanceCounterCategory.
Overload
| PerformanceCounterCategory() |
Menginisialisasi instans baru kelas PerformanceCounterCategory, membiarkan properti CategoryName kosong, dan mengatur properti MachineName ke komputer lokal. |
| PerformanceCounterCategory(String) |
Menginisialisasi instans baru kelas PerformanceCounterCategory, mengatur properti CategoryName ke nilai yang ditentukan, dan mengatur properti MachineName ke komputer lokal. |
| PerformanceCounterCategory(String, String) |
Menginisialisasi instans baru kelas PerformanceCounterCategory dan mengatur properti CategoryName dan MachineName ke nilai yang ditentukan. |
PerformanceCounterCategory()
Menginisialisasi instans baru kelas PerformanceCounterCategory, membiarkan properti CategoryName kosong, dan mengatur properti MachineName ke komputer lokal.
public:
PerformanceCounterCategory();
public PerformanceCounterCategory ();
Public Sub New ()
Contoh
Contoh kode berikut menerima nama PerformanceCounterCategory dan nama komputer dari baris perintah. Ini membuat PerformanceCounterCategory menggunakan kelebihan beban konstruktor yang sesuai untuk jumlah parameter yang disediakan, lalu menampilkan propertinya.
public static void Main(string[] args)
{
string categoryName = "";
string machineName = "";
PerformanceCounterCategory pcc;
// Copy the supplied arguments into the local variables.
try
{
categoryName = args[0];
machineName = args[1]=="."? "": args[1];
}
catch(Exception ex)
{
// Ignore the exception from non-supplied arguments.
}
// Create a PerformanceCounterCategory object using
// the appropriate constructor.
if (categoryName.Length==0)
{
pcc = new PerformanceCounterCategory();
}
else if(machineName.Length==0)
{
pcc = new PerformanceCounterCategory(categoryName);
}
else
{
pcc = new PerformanceCounterCategory(categoryName, 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 PerformanceCounterCategory
' Copy the supplied arguments into the local variables.
Try
categoryName = args(0)
machineName = IIf(args(1) = ".", "", args(1))
Catch ex As Exception
' Ignore the exception from non-supplied arguments.
End Try
' Create a PerformanceCounterCategory object using
' the appropriate constructor.
If categoryName.Length = 0 Then
pcc = New PerformanceCounterCategory
ElseIf machineName.Length = 0 Then
pcc = New PerformanceCounterCategory(categoryName)
Else
pcc = New PerformanceCounterCategory(categoryName, machineName)
End If
' 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
Keterangan
Properti CategoryName harus diatur sebelum mengaitkan instans PerformanceCounterCategory ini dengan objek performa di server. Jika tidak, pengecualian akan dilemparkan.
Lihat juga
Berlaku untuk
PerformanceCounterCategory(String)
Menginisialisasi instans baru kelas PerformanceCounterCategory, mengatur properti CategoryName ke nilai yang ditentukan, dan mengatur properti MachineName ke komputer lokal.
public:
PerformanceCounterCategory(System::String ^ categoryName);
public PerformanceCounterCategory (string categoryName);
new System.Diagnostics.PerformanceCounterCategory : string -> System.Diagnostics.PerformanceCounterCategory
Public Sub New (categoryName As String)
Parameter
- categoryName
- String
Nama kategori penghitung kinerja, atau objek performa, untuk mengaitkan instans PerformanceCounterCategory ini.
Pengecualian
categoryName adalah string kosong ("").
categoryName
null.
Contoh
Contoh kode berikut menerima nama PerformanceCounterCategory dan nama komputer dari baris perintah. Ini membuat PerformanceCounterCategory menggunakan kelebihan beban konstruktor yang sesuai untuk jumlah parameter yang disediakan, lalu menampilkan propertinya.
public static void Main(string[] args)
{
string categoryName = "";
string machineName = "";
PerformanceCounterCategory pcc;
// Copy the supplied arguments into the local variables.
try
{
categoryName = args[0];
machineName = args[1]=="."? "": args[1];
}
catch(Exception ex)
{
// Ignore the exception from non-supplied arguments.
}
// Create a PerformanceCounterCategory object using
// the appropriate constructor.
if (categoryName.Length==0)
{
pcc = new PerformanceCounterCategory();
}
else if(machineName.Length==0)
{
pcc = new PerformanceCounterCategory(categoryName);
}
else
{
pcc = new PerformanceCounterCategory(categoryName, 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 PerformanceCounterCategory
' Copy the supplied arguments into the local variables.
Try
categoryName = args(0)
machineName = IIf(args(1) = ".", "", args(1))
Catch ex As Exception
' Ignore the exception from non-supplied arguments.
End Try
' Create a PerformanceCounterCategory object using
' the appropriate constructor.
If categoryName.Length = 0 Then
pcc = New PerformanceCounterCategory
ElseIf machineName.Length = 0 Then
pcc = New PerformanceCounterCategory(categoryName)
Else
pcc = New PerformanceCounterCategory(categoryName, machineName)
End If
' 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
Lihat juga
Berlaku untuk
PerformanceCounterCategory(String, String)
Menginisialisasi instans baru kelas PerformanceCounterCategory dan mengatur properti CategoryName dan MachineName ke nilai yang ditentukan.
public:
PerformanceCounterCategory(System::String ^ categoryName, System::String ^ machineName);
public PerformanceCounterCategory (string categoryName, string machineName);
new System.Diagnostics.PerformanceCounterCategory : string * string -> System.Diagnostics.PerformanceCounterCategory
Public Sub New (categoryName As String, machineName As String)
Parameter
- categoryName
- String
Nama kategori penghitung kinerja, atau objek performa, untuk mengaitkan instans PerformanceCounterCategory ini.
- machineName
- String
Komputer tempat kategori penghitung kinerja dan penghitung terkait berada.
Pengecualian
categoryName
null.
Contoh
Contoh kode berikut menerima nama PerformanceCounterCategory dan nama komputer dari baris perintah. Ini membuat PerformanceCounterCategory menggunakan kelebihan beban konstruktor yang sesuai untuk jumlah parameter yang disediakan, lalu menampilkan propertinya.
public static void Main(string[] args)
{
string categoryName = "";
string machineName = "";
PerformanceCounterCategory pcc;
// Copy the supplied arguments into the local variables.
try
{
categoryName = args[0];
machineName = args[1]=="."? "": args[1];
}
catch(Exception ex)
{
// Ignore the exception from non-supplied arguments.
}
// Create a PerformanceCounterCategory object using
// the appropriate constructor.
if (categoryName.Length==0)
{
pcc = new PerformanceCounterCategory();
}
else if(machineName.Length==0)
{
pcc = new PerformanceCounterCategory(categoryName);
}
else
{
pcc = new PerformanceCounterCategory(categoryName, 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 PerformanceCounterCategory
' Copy the supplied arguments into the local variables.
Try
categoryName = args(0)
machineName = IIf(args(1) = ".", "", args(1))
Catch ex As Exception
' Ignore the exception from non-supplied arguments.
End Try
' Create a PerformanceCounterCategory object using
' the appropriate constructor.
If categoryName.Length = 0 Then
pcc = New PerformanceCounterCategory
ElseIf machineName.Length = 0 Then
pcc = New PerformanceCounterCategory(categoryName)
Else
pcc = New PerformanceCounterCategory(categoryName, machineName)
End If
' 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