共用方式為


CpuCollection.Count 屬性

Gets the number of Cpu entries in the collection.

命名空間:  Microsoft.SqlServer.Management.Smo
組件:  Microsoft.SqlServer.Smo (在 Microsoft.SqlServer.Smo.dll 中)

語法

'宣告
Public ReadOnly Property Count As Integer 
    Get
'用途
Dim instance As CpuCollection 
Dim value As Integer 

value = instance.Count
public int Count { get; }
public:
virtual property int Count {
    int get () sealed;
}
abstract Count : int 
override Count : int
final function get Count () : int

屬性值

型別:System.Int32
Returns the number of Cpu entries in the collection. The return type is an T:[System.int] value.

實作

ICollection.Count

範例

The following example shows how to determine the total number of CPUs on an instance of SQL Server.

C#

using System;
using Microsoft.SqlServer.Management.Smo;

namespace samples
{
    class Program
    {
        static void Main(string[] args)
        {
            Server dbServer = new Server("(local)");
            dbServer.Refresh();
            Console.WriteLine("Total CPUs: {0}",
                dbServer.AffinityInfo.Cpus.Count);
        }
    }
}

Powershell

$dbServer = new-Object Microsoft.SqlServer.Management.Smo.Server("(local)")
$dbServer.Refresh()
Foreach ($cpu in $dbServer.AffinityInfo.Cpus)
{
   Write-Host "Total CPUs:" $dbServer.AffinityInfo.Cpus.Count
}

請參閱

參考

CpuCollection 類別

Microsoft.SqlServer.Management.Smo 命名空間