PropertyValueCollection.Remove(Object) 方法   
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
从此集合中删除指定的属性值。
public:
 void Remove(System::Object ^ value);public void Remove (object value);public void Remove (object? value);member this.Remove : obj -> unitPublic Sub Remove (value As Object)参数
- value
- Object
要删除的属性值。
例外
属性值为空引用(在 Visual Basic 中为 Nothing)。
调用基础接口时出错。
示例
// Bind to the AD object  
DirectoryEntry myUser = new DirectoryEntry("LDAP://AdServer:389/CN=MyUsername,CN=Users,DC=contoso,DC=com");  
// Get the attribute  
PropertyValueCollection testAttribute = myUser.Properties["someAttribute"];  
// Find the item in the collection that we want to delete  
DNWithString dnwsItemToRemove = null;  
foreach (DNWithString dnwsItem in testAttribute)  
{  
    if (dnwsItem.StringValue.Equals("SomeValue"))  
    {  
        dnwsItemToRemove = dnwsItem;  
        break;  
    }  
}  
// Delete it  
testAttribute.Remove(dnwsItemToRemove);  
// Store the data  
myUser.CommitChanges();  
注解
使用多值字符串属性值时, Remove 方法将成功删除正确的项。 但是,使用多值 DNWithString 属性值 (很难按名称标识正确的项,因为用于存储 DNWithString 项的 DNWithString COM 类有 2 个表示项) 的字符串属性。 删除此类项的方法是在集合 (查找对象,方法是循环访问) 的所有项,然后使用刚刚找到的对象指针调用 Remove 函数。 下面的示例对此进行了说明。