Share via

SPContentTypeUsage.GetUsages Method

Returns a list of SPContentTypeUsage objects with information about where the specified content type is in use.

Namespace:  Microsoft.SharePoint
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: No


<SubsetCallableExcludeMemberAttribute(SubsetCallableExcludeMemberType.InterfaceType)> _
Public Shared Function GetUsages ( _
    contentType As SPContentType _
) As IList(Of SPContentTypeUsage)
Dim contentType As SPContentType
Dim returnValue As IList(Of SPContentTypeUsage)

returnValue = SPContentTypeUsage.GetUsages(contentType)
public static IList<SPContentTypeUsage> GetUsages(
    SPContentType contentType


Return Value

Type: System.Collections.Generic.IList<SPContentTypeUsage>
A collection of SPContentTypeUsage objects.


This method returns a generic list of SPContentTypeUsage objects that contain information about each use of a content type in the site collection. If the content type is not used, the method returns an empty list (Count = 0).


A content type is “used” if any content type derived from it is present in an SPContentTypeCollection collection at the site or list level anywhere within its scope. For more information, see Content Type Scope.


The following example is a console application that gets the usage collection for the built-in content type “Item.” The application counts the number of times it is used as a site content type and the number of times it is used as a list content type, and then prints the totals to the console.

Imports System
Imports System.Collections.Generic
Imports Microsoft.SharePoint

Module ConsoleApp
   Sub Main()
      Using siteCollection As SPSite = New SPSite("https://localhost")
         Using rootWeb As SPWeb = siteCollection.RootWeb

            ' Get the content type.
            Dim contentType As SPContentType = _

            'Get the usage collection.
            Dim usages As IList(Of SPContentTypeUsage) = _

            ' Count the site and list types.
            Dim listTypes As Integer = 0
            Dim siteTypes As Integer = 0
            For Each usage As SPContentTypeUsage In usages
               If usage.IsUrlToList Then
                  listTypes += 1
                  siteTypes += 1
               End If
            Next usage

            Console.Write("The content type is inherited by {0} site content types", siteTypes)
            Console.WriteLine(" and {0} list content types.", listTypes)

         End Using
      End Using
      Console.Write(vbCrLf + "Press ENTER to continue...")
   End Sub

End Module
using System;
using System.Collections.Generic;
using Microsoft.SharePoint;

namespace Test
   class ConsoleApp
      static void Main(string[] args)
         using (SPSite siteCollection = new SPSite("https://localhost"))
            using (SPWeb rootWeb = siteCollection.RootWeb)
               // Get the content type.
               SPContentType contentType =

               //Get the usage collection.
               IList<SPContentTypeUsage> usages = SPContentTypeUsage.GetUsages(contentType);

               // Count the site and list types.
               int listTypes = 0;
               int siteTypes = 0;
               foreach (SPContentTypeUsage usage in usages)
                  if (usage.IsUrlToList)

               Console.Write("The content type is inherited by {0} site content types", siteTypes);
               Console.WriteLine(" and {0} list content types.", listTypes);
         Console.Write("\nPress ENTER to continue...");

When the application is run against a Web site created with the Team Site template, it prints the following output to the console.

The content type is inherited by 33 site content types and 20 list content types.

Press ENTER to continue...

See Also


SPContentTypeUsage Class

SPContentTypeUsage Members

Microsoft.SharePoint Namespace

Other Resources

Site and List Content Types

Creating Content Types