RootWeb vs OpenWeb in SharePoint 2013

in this blog we compare the RootWeb and OpenWeb in SharePoint 2013.

Let's get back to some basic stuff in Sharepoint 2013 this time around. When I was just scanning through all the properties and methods of SPWEB,  there is a property called ROOTWEB that caught my attention.
 
Hence I decided to dig further and understand why ROOTWEB property is introduced though we have OpenWeb function to do the same job for us.
 
Here is the difference between RootWeb and OpenWeb  of SPWEB objects are summarised as follow.
 
Rootweb
  1. It is a  property of SPWeb
     Example :SPWeb.Rootweb 
  2. No need to dispose the objects explicitly.
  3. It returns topmost rootweb of the site collection.
  4. Sample Code Usage is given below
  1. using (SPSite site = new SPSite("http://mysite"))      
  2. {      
  3.           
  4.       SPWeb web = site.RootWeb    
  5.     {       
  6.         // Sample Code      
  7.     }     
  8. }  
OpenWeb
  1. It is a method of SPWeb
    Example : SPWeb myweb = SPWeb.OpenWeb(); 
  2. SPWeb object has to be disposed explicitly
  3. Sample Code usage is provided below 
  1.  using (SPSite site = new SPSite("http://mysite/subsite"))    
  2. {    
  3.         
  4.     using (SPWeb web = site.OpenWeb())    
  5.     {     
  6.         // Sample Code    
  7.     }    
  8. }  
 Happy SharePointing.