SPRoleDefinitionCollection.Count Property
Gets the number of role definitions in the collection.
Namespace: Microsoft.SharePoint
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: Yes
Available in SharePoint Online
Syntax
'Declaration
Public Overrides ReadOnly Property Count As Integer
Get
'Usage
Dim instance As SPRoleDefinitionCollection
Dim value As Integer
value = instance.Count
public override int Count { get; }
Property Value
Type: System.Int32
A 32-bit integer that indicates the number of role definitions.
Implements
Examples
The following code example returns the number of role definitions from a specified Web site that has unique role definitions.
using(SPSite oSiteCollection = new SPSite("http://Server_Name/Subsite1"))
{
using (SPWeb oWebsite = oSiteCollection.OpenWeb())
{
if (oWebsite.HasUniqueRoleDefinitions)
{
int intRoleDefinitionCount = oWebsite.RoleDefinitions.Count;
}
}
}
Using oSiteCollection As New SPSite("http://Server_Name/Subsite1")
Using oWebsite As SPWeb = oSiteCollection.OpenWeb()
If oWebsite.HasUniqueRoleDefinitions Then
Dim intRoleDefinitionCount As Integer = oWebsite.RoleDefinitions.Count
End If
End Using
End Using
Note
Certain objects implement the IDisposable interface, and you must avoid retaining these objects in memory after they are no longer needed. For information about good coding practices, see Disposing Objects.
See Also
Reference
SPRoleDefinitionCollection Class