SPGroupCollection.RemoveByID 方法

Removes the group with the specified member ID from the collection.

命名空间:  Microsoft.SharePoint
程序集:  Microsoft.SharePoint(位于 Microsoft.SharePoint.dll 中)

语法

声明
Public Sub RemoveByID ( _
    id As Integer _
)
用法
Dim instance As SPGroupCollection
Dim id As Integer

instance.RemoveByID(id)
public void RemoveByID(
    int id
)

参数

  • id
    类型:System.Int32

    A 32-bit integer that specifies the member ID of the group to be removed.

异常

异常 条件
SPException

The group collection is read-only.

备注

The value of the id parameter corresponds to the unique member ID for the group, which equals the ID property of the SPMember class. Use the Remove method to remove a group at a specified index in the group collection.

示例

The following code example removes all groups that have IDs between 50 and 100 from the site collection.

Dim webSite As SPWeb = SPContext.Current.Site.RootWeb
Try
    Dim myGroups As SPGroupCollection = webSite.SiteGroups

    Dim i As Integer
    For i = 50 To 100
        myGroups.RemoveByID(i)
    Next i
Finally
    webSite.Dispose()
End Try
using (SPWeb oWebsiteRoot = SPContext.Current.Site.RootWeb)
{
    SPGroupCollection collGroups = oWebsiteRoot.SiteGroups;

    for (int intIndex=50; intIndex<101; intIndex++)
    {
        collGroups.RemoveByID(intIndex);
    }
}

备注

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 Disposing Objects.

另请参阅

引用

SPGroupCollection 类

SPGroupCollection 成员

Microsoft.SharePoint 命名空间