SharePoint : Programmatically enabling the content approval for library

  1. //Enabling the content approval for library  
  2.                     try  
  3.                     {  
  4.                         string libraryName = "LibraryName";  
  5.                         SPList list = web.Lists[libraryName];  
  6.                         if (list != null)  
  7.                         {  
  8.                             list.EnableModeration = true;  
  9.                             list.Update();  
  10.                         }  
  11.                     }  
  12.                     catch (Exception ex)  
  13.                     {  
  14.                        //Handle the exception  
  15.                     }