Spcontenttypeid ID = New Spcontenttypeid ( Basecontenttypeid );
Ilist < Spcontenttype > Contenttypes = Web . Contenttypes . Cast < Spcontenttype > (). Where ( C => C . ID . Ischildof ( ID )). Tolist ();
Using ( Spsite Site = New Spsite ( Spcontext . Current . Site . URL ))
{
Using ( Spweb Web = Site . Openweb ())
{
Spcontenttypecollection Allcontenttypes = Web . Contenttypes ;
Spcontenttypecollection Doccontenttypes = Null ;
Foreach ( Spcontenttype Objcontenttype In Allcontenttypes )
{
If ( Objcontenttype . Parent . Name = "Document" )
{
Doccontenttypes . Add ( Objcontenttype );
}
}
// Doccontenttypes contains all content types derived from content type "document". You can implement additional checks and add this into a drop down list.
}
}
You can use the name to retrieve:
SpcontenttypeSpct=Web.Availablecontenttypes["Contenttypename"];