SPGroupCollection.Remove method (String)
從集合中移除具有指定名稱的群組。
Namespace: Microsoft.SharePoint
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Syntax
'宣告
Public Sub Remove ( _
name As String _
)
'用途
Dim instance As SPGroupCollection
Dim name As String
instance.Remove(name)
public void Remove(
string name
)
參數
name
Type: System.String字串,包含要移除群組的名稱。
Exceptions
Exception | Condition |
---|---|
SPException | 群組集合是唯讀的。 |
Examples
下列程式碼範例從目前的網站集合中移除指定的群組。
Dim webSite As SPWeb = SPContext.Current.Site.RootWeb
Try
Dim myGroups As SPGroupCollection = webSite.SiteGroups
myGroups.Remove("Group_Name")
Finally
webSite.Dispose()
End Try
using (SPWeb oWebsiteRoot = SPContext.Current.Site.RootWeb)
{
SPGroupCollection collGroups = oWebsiteRoot.SiteGroups;
collGroups.Remove("Group_Name");
}
注意事項 |
---|
某些物件實作IDisposable介面,並且您必須避免之後不再需要保留這些物件在記憶體中。良好的程式碼撰寫方式的相關資訊,請參閱Disposing Objects。 |