Are you looking for some code like this?
if (SiteCollectionURL == null)
{
SiteCollectionURL = SPContext.Current.Web.Url;
}
SPSite refSite = new SPSite(SiteCollectionURL);
SPWeb refWeb = refSite.OpenWeb("/");
SPList refList = refWeb.Lists[myListName];
This is a
web page so the user can specify the URL in a QueryString
parameter; if they don't, I just use the current
site from the SPContext.