This documentation is archived and is not being maintained.
StateBag.Remove Method
.NET Framework 1.1
Removes the specified key/value pair from the StateBag object.
[Visual Basic] Public Sub Remove( _ ByVal key As String _ ) [C#] public void Remove( string key ); [C++] public: void Remove( String* key ); [JScript] public function Remove( key : String );
Parameters
- key
- The item to remove.
Example
[Visual Basic, C#, JScript] The following example demonstrates using the Remove method.
[Visual Basic] Sub MovePiece(fromPosition As String, toPosition As String) Dim bag As StateBag = ViewState Dim piece As Object = bag(fromPosition) If Not (piece Is Nothing) Then bag.Remove(fromPosition) bag.Add(toPosition, piece) RenderBoard() Else Throw New InvalidPositionException("There is no game piece at the ""from"" position.") End If End Sub 'MovePiece [C#] void MovePiece(string fromPosition, string toPosition) { StateBag bag = ViewState; object piece = bag[fromPosition]; if (piece != null) { bag.Remove(fromPosition); bag.Add(toPosition, piece); RenderBoard(); } else { throw new InvalidPositionException("There is no game piece at the \"from\" position."); } } [JScript] function MovePiece(fromPosition : String, toPosition : String) { var bag : StateBag = ViewState; var piece = bag[fromPosition]; if (piece != null) { bag.Remove(fromPosition); bag.Add(toPosition, piece); RenderBoard(); } else { throw new InvalidPositionException("There is no game piece at the \"from\" position."); } }
[C++] No example is available for C++. To view a Visual Basic, C#, or JScript example, click the Language Filter button
in the upper-left corner of the page.
Requirements
Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family
See Also
StateBag Class | StateBag Members | System.Web.UI Namespace | ViewState | Clear | Item | Add
Show: