What is difference between:
If both are same, Which is considered to be good practice?
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It only takes a minute to sign up.Sign up to join this community
I don't believe there is a difference in terms of what they return back (the string representation of the root URL of the site).
However, in the second case you are referencing both an SPSite and SPWeb object whereas in the first you are only referencing the SPSite object (so there might be some minor performance considerations if all you are looking for is the URL to the site).
In addition I would think the the context of the code you are writing would favor one over the other (e.g. if you have code that is scoped at the site level it would make more sense to just get the SPSite object Url; if your code was scoped at the web level (for example, doing something to the root SPWeb object and then traversing down to subsequent children webs) then referencing the rootweb.url would make more consistent sense to me).
In both cases you would need to make sure you are following proper disposal practices: http://msdn.microsoft.com/en-us/library/ms468609.aspx