PropertyValueCollection.Remove(Object) メソッド

定義

このコレクションから指定したプロパティ値を削除します。

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)

パラメーター

value
Object

削除するプロパティ値。

例外

プロパティ値は null 参照 (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 関数を呼び出す方法です。 これは次の例に示されています。

適用対象