Extension Methods in C#

 Below are the 2 methods which will help you know if the selected document library item is a folder or is the selected list is a Document library or not.   
  1. public static class ExtensionMethods  
  2. {  
  3.    public static bool IsFolder(this SPListItem item)  
  4.    {  
  5.       return (item.Folder != null);  
  6.    }  
  7.   
  8.    public static bool IsDocumentLibrary(this SPList list)  
  9.    {  
  10.       return (list.BaseType == SPBaseType.DocumentLibrary);  
  11.    }     
  12. }  
 Happy Coding !!!