PropertyValueCollection.Remove(Object) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Removes a specified property value from this collection.
public:
void Remove(System::Object ^ value);
public void Remove (object? value);
public void Remove (object value);
member this.Remove : obj -> unit
Public Sub Remove (value As Object)
Parameters
- value
- Object
The property value to remove.
Exceptions
The property value is a null reference (Nothing
in Visual Basic).
An error occurred during the call to the underlying interface.
Examples
// 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();
Remarks
When working with a multi-valued string property value, the Remove method will successfully remove the correct item. However, identifying the correct items by name is difficult with a multi-valued DNWithString property value (as the DNWithString COM class, which is used to store the DNWithString items, has 2 string properties representing the item). The way to remove such items is to find the object in the collection (by looping thru all the items), then call the Remove function with the object's pointer that you just found. This is illustrated in the example below.
Applies to
.NET
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기