This documentation is archived and is not being maintained.

SerializationInfo.GetValue Method

Retrieves a value from the SerializationInfo store.

Namespace:  System.Runtime.Serialization
Assembly:  mscorlib (in mscorlib.dll)

member GetValue : 
        name:string * 
        type:Type -> Object 


Type: System.String
The name associated with the value to retrieve.
Type: System.Type
The Type of the value to retrieve. If the stored value cannot be converted to this type, the system will throw a InvalidCastException.

Return Value

Type: System.Object
The object of the specified Type associated with name.


name or type is a null reference (Nothing in Visual Basic).


The value associated with name cannot be converted to type.


An element with the specified name is not found in the current instance.

If the data stored in the SerializationInfo is of the type requested (or one of its derived classes), that value is returned directly. Otherwise, IFormatterConverter.Convert is called to convert it to the appropriate type.

The value returned by the GetValue method can always be safely cast to the type specified in the type parameter.

The following code example demonstrates the use of the GetValue method:

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.