Gets the collection of cross-site groups for the site.
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
The following code example uses the Groups property to return the collection of groups for a specified site in the current site collection.
Using webSite As SPWeb = SPContext.Current.Site.OpenWeb("Website_URL") Dim groups As SPGroupCollection = webSite.Groups For Each group As SPGroup In groups Response.Write((SPEncode.HtmlEncode(group.Name) + "<BR>")) Next group End Using
Certain objects implement the IDisposable interface, and you must avoid retaining these objects in memory after they are no longer needed. For information about good coding practices, see Best Practices: Using Disposable Windows SharePoint Services Objects.