ViewDataDictionary.Remove Method
Removes an object from the collection.
Assembly: System.Web.Mvc (in System.Web.Mvc.dll)
| Name | Description | |
|---|---|---|
![]() | Remove(KeyValuePair<String, Object>) | Removes the first occurrence of a specified object from the collection. |
![]() | Remove(String) | Removes the element from the collection using the specified key. |
ViewDataDictionary.Remove Method (KeyValuePair<String, Object>)
Removes the first occurrence of a specified object from the collection.
Parameters
- item
-
Type:
System.Collections.Generic.KeyValuePair<String, Object>
The object to remove from the collection.
Return Value
Type: System.Booleantrue if item was successfully removed from the collection; otherwise, false. This method also returns false if item is not found in the collection.
Implements
ICollection<'T>.Remove('T)| Exception | Condition |
|---|---|
| NotSupportedException | The collection is read-only. |
ViewDataDictionary.Remove Method (String)
Removes the element from the collection using the specified key.
Parameters
- key
-
Type:
System.String
The key of the element to remove.
Return Value
Type: System.Booleantrue if the element is successfully removed; otherwise, false. This method also returns false if key was not found in the original collection.
| Exception | Condition |
|---|---|
| NotSupportedException | The collection is read-only. |
| ArgumentNullException | key is null. |
