PerformanceCounterCategory Konstruktorer

Definition

Initierar en ny instans av PerformanceCounterCategory klassen.

Överlagringar

Name Description
PerformanceCounterCategory()

Initierar en ny instans av PerformanceCounterCategory klassen, lämnar CategoryName egenskapen tom och anger MachineName egenskapen till den lokala datorn.

PerformanceCounterCategory(String)

Initierar en ny instans av PerformanceCounterCategory klassen, anger CategoryName egenskapen till det angivna värdet och anger MachineName egenskapen till den lokala datorn.

PerformanceCounterCategory(String, String)

Initierar en ny instans av PerformanceCounterCategory klassen och anger CategoryName egenskaperna och MachineName till de angivna värdena.

PerformanceCounterCategory()

Källa:
PerformanceCounterCategory.cs
Källa:
PerformanceCounterCategory.cs
Källa:
PerformanceCounterCategory.cs
Källa:
PerformanceCounterCategory.cs
Källa:
PerformanceCounterCategory.cs
Källa:
PerformanceCounterCategory.cs
Källa:
PerformanceCounterCategory.cs
Källa:
PerformanceCounterCategory.cs

Initierar en ny instans av PerformanceCounterCategory klassen, lämnar CategoryName egenskapen tom och anger MachineName egenskapen till den lokala datorn.

public:
 PerformanceCounterCategory();
public PerformanceCounterCategory();
Public Sub New ()

Exempel

I följande kodexempel accepteras ett PerformanceCounterCategory namn och ett datornamn från kommandoraden. Den skapar en PerformanceCounterCategory användning av konstruktorns överlagring som är lämplig för det antal parametrar som anges och visar sedan dess egenskaper.

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

Kommentarer

Egenskapen CategoryName måste anges innan den här PerformanceCounterCategory instansen associeras med ett prestandaobjekt på servern. Annars utlöses ett undantag.

Se även

Gäller för

PerformanceCounterCategory(String)

Källa:
PerformanceCounterCategory.cs
Källa:
PerformanceCounterCategory.cs
Källa:
PerformanceCounterCategory.cs
Källa:
PerformanceCounterCategory.cs
Källa:
PerformanceCounterCategory.cs
Källa:
PerformanceCounterCategory.cs
Källa:
PerformanceCounterCategory.cs
Källa:
PerformanceCounterCategory.cs

Initierar en ny instans av PerformanceCounterCategory klassen, anger CategoryName egenskapen till det angivna värdet och anger MachineName egenskapen till den lokala datorn.

public:
 PerformanceCounterCategory(System::String ^ categoryName);
public PerformanceCounterCategory(string categoryName);
new System.Diagnostics.PerformanceCounterCategory : string -> System.Diagnostics.PerformanceCounterCategory
Public Sub New (categoryName As String)

Parametrar

categoryName
String

Namnet på prestandaräknarens kategori eller prestandaobjekt som den här PerformanceCounterCategory instansen ska associeras med.

Undantag

categoryName är en tom sträng ("").

categoryName är null.

Exempel

I följande kodexempel accepteras ett PerformanceCounterCategory namn och ett datornamn från kommandoraden. Den skapar en PerformanceCounterCategory användning av konstruktorns överlagring som är lämplig för det antal parametrar som anges och visar sedan dess egenskaper.

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

Se även

Gäller för

PerformanceCounterCategory(String, String)

Källa:
PerformanceCounterCategory.cs
Källa:
PerformanceCounterCategory.cs
Källa:
PerformanceCounterCategory.cs
Källa:
PerformanceCounterCategory.cs
Källa:
PerformanceCounterCategory.cs
Källa:
PerformanceCounterCategory.cs
Källa:
PerformanceCounterCategory.cs
Källa:
PerformanceCounterCategory.cs

Initierar en ny instans av PerformanceCounterCategory klassen och anger CategoryName egenskaperna och MachineName till de angivna värdena.

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)

Parametrar

categoryName
String

Namnet på prestandaräknarens kategori eller prestandaobjekt som den här PerformanceCounterCategory instansen ska associeras med.

machineName
String

Den dator där prestandaräknarens kategori och dess associerade räknare finns.

Undantag

categoryName är en tom sträng ("").

-eller-

Syntaxen machineName är ogiltig.

categoryName är null.

Exempel

I följande kodexempel accepteras ett PerformanceCounterCategory namn och ett datornamn från kommandoraden. Den skapar en PerformanceCounterCategory användning av konstruktorns överlagring som är lämplig för det antal parametrar som anges och visar sedan dess egenskaper.

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

Se även

Gäller för