Breyta

Deila með


SerializationInfo.AddValue Method

Definition

Adds a value into the SerializationInfo.

Overloads

AddValue(String, Object, Type)

Adds a value into the SerializationInfo store, where value is associated with name and is serialized as being of Typetype.

AddValue(String, UInt64)

Adds a 64-bit unsigned integer value into the SerializationInfo store.

AddValue(String, UInt32)

Adds a 32-bit unsigned integer value into the SerializationInfo store.

AddValue(String, UInt16)

Adds a 16-bit unsigned integer value into the SerializationInfo store.

AddValue(String, Single)

Adds a single-precision floating-point value into the SerializationInfo store.

AddValue(String, SByte)

Adds an 8-bit signed integer value into the SerializationInfo store.

AddValue(String, Object)

Adds the specified object into the SerializationInfo store, where it is associated with a specified name.

AddValue(String, Int64)

Adds a 64-bit signed integer value into the SerializationInfo store.

AddValue(String, Int32)

Adds a 32-bit signed integer value into the SerializationInfo store.

AddValue(String, Int16)

Adds a 16-bit signed integer value into the SerializationInfo store.

AddValue(String, Double)

Adds a double-precision floating-point value into the SerializationInfo store.

AddValue(String, Decimal)

Adds a decimal value into the SerializationInfo store.

AddValue(String, DateTime)

Adds a DateTime value into the SerializationInfo store.

AddValue(String, Char)

Adds a Unicode character value into the SerializationInfo store.

AddValue(String, Byte)

Adds an 8-bit unsigned integer value into the SerializationInfo store.

AddValue(String, Boolean)

Adds a Boolean value into the SerializationInfo store.

AddValue(String, Object, Type)

Source:
SerializationInfo.cs
Source:
SerializationInfo.cs
Source:
SerializationInfo.cs

Adds a value into the SerializationInfo store, where value is associated with name and is serialized as being of Typetype.

public:
 void AddValue(System::String ^ name, System::Object ^ value, Type ^ type);
public void AddValue (string name, object? value, Type type);
public void AddValue (string name, object value, Type type);
member this.AddValue : string * obj * Type -> unit
Public Sub AddValue (name As String, value As Object, type As Type)

Parameters

name
String

The name to associate with the value, so it can be deserialized later.

value
Object

The value to be serialized. Any children of this object will automatically be serialized.

type
Type

The Type to associate with the current object. This parameter must always be the type of the object itself or of one of its base classes.

Exceptions

If name or type is null.

A value has already been associated with name.

Remarks

The assigned type is always the type of the object, or one of its parents.

If two values are added with names that differ only by case, no exception will be thrown, which is not a recommended practice. However, adding two values with the exact same name will cause the SerializationException to be thrown.

Applies to

AddValue(String, UInt64)

Source:
SerializationInfo.cs
Source:
SerializationInfo.cs
Source:
SerializationInfo.cs

Important

This API is not CLS-compliant.

Adds a 64-bit unsigned integer value into the SerializationInfo store.

public:
 void AddValue(System::String ^ name, System::UInt64 value);
[System.CLSCompliant(false)]
public void AddValue (string name, ulong value);
[<System.CLSCompliant(false)>]
member this.AddValue : string * uint64 -> unit
Public Sub AddValue (name As String, value As ULong)

Parameters

name
String

The name to associate with the value, so it can be deserialized later.

value
UInt64

The value to serialize.

Attributes

Exceptions

The name parameter is null.

A value has already been associated with name.

Remarks

If two values are added with names that differ only by case, no exception will be thrown, which is not a recommended practice. However, adding two values with the exact same name will cause the SerializationException to be thrown.

Applies to

AddValue(String, UInt32)

Source:
SerializationInfo.cs
Source:
SerializationInfo.cs
Source:
SerializationInfo.cs

Important

This API is not CLS-compliant.

Adds a 32-bit unsigned integer value into the SerializationInfo store.

public:
 void AddValue(System::String ^ name, System::UInt32 value);
[System.CLSCompliant(false)]
public void AddValue (string name, uint value);
[<System.CLSCompliant(false)>]
member this.AddValue : string * uint32 -> unit
Public Sub AddValue (name As String, value As UInteger)

Parameters

name
String

The name to associate with the value, so it can be deserialized later.

value
UInt32

The UInt32 value to serialize.

Attributes

Exceptions

The name parameter is null.

A value has already been associated with name.

Remarks

If two values are added with names that differ only by case, no exception will be thrown, which is not a recommended practice. However, adding two values with the exact same name will cause the SerializationException to be thrown.

Applies to

AddValue(String, UInt16)

Source:
SerializationInfo.cs
Source:
SerializationInfo.cs
Source:
SerializationInfo.cs

Important

This API is not CLS-compliant.

Adds a 16-bit unsigned integer value into the SerializationInfo store.

public:
 void AddValue(System::String ^ name, System::UInt16 value);
[System.CLSCompliant(false)]
public void AddValue (string name, ushort value);
[<System.CLSCompliant(false)>]
member this.AddValue : string * uint16 -> unit
Public Sub AddValue (name As String, value As UShort)

Parameters

name
String

The name to associate with the value, so it can be deserialized later.

value
UInt16

The UInt16 value to serialize.

Attributes

Exceptions

The name parameter is null.

A value has already been associated with name.

Remarks

If two values are added with names that differ only by case, no exception will be thrown, which is not a recommended practice. However, adding two values with the exact same name will cause the SerializationException to be thrown.

Applies to

AddValue(String, Single)

Source:
SerializationInfo.cs
Source:
SerializationInfo.cs
Source:
SerializationInfo.cs

Adds a single-precision floating-point value into the SerializationInfo store.

public:
 void AddValue(System::String ^ name, float value);
public void AddValue (string name, float value);
member this.AddValue : string * single -> unit
Public Sub AddValue (name As String, value As Single)

Parameters

name
String

The name to associate with the value, so it can be deserialized later.

value
Single

The single value to serialize.

Exceptions

The name parameter is null.

A value has already been associated with name.

Remarks

If two values are added with names that differ only by case, no exception will be thrown, which is not a recommended practice. However, adding two values with the exact same name will cause the SerializationException to be thrown.

Applies to

AddValue(String, SByte)

Source:
SerializationInfo.cs
Source:
SerializationInfo.cs
Source:
SerializationInfo.cs

Important

This API is not CLS-compliant.

Adds an 8-bit signed integer value into the SerializationInfo store.

public:
 void AddValue(System::String ^ name, System::SByte value);
[System.CLSCompliant(false)]
public void AddValue (string name, sbyte value);
[<System.CLSCompliant(false)>]
member this.AddValue : string * sbyte -> unit
Public Sub AddValue (name As String, value As SByte)

Parameters

name
String

The name to associate with the value, so it can be deserialized later.

value
SByte

The Sbyte value to serialize.

Attributes

Exceptions

The name parameter is null.

A value has already been associated with name.

Remarks

If two values are added with names that differ only by case, no exception will be thrown, which is not a recommended practice. However, adding two values with the exact same name will cause the SerializationException to be thrown.

Applies to

AddValue(String, Object)

Source:
SerializationInfo.cs
Source:
SerializationInfo.cs
Source:
SerializationInfo.cs

Adds the specified object into the SerializationInfo store, where it is associated with a specified name.

public:
 void AddValue(System::String ^ name, System::Object ^ value);
public void AddValue (string name, object? value);
public void AddValue (string name, object value);
member this.AddValue : string * obj -> unit
Public Sub AddValue (name As String, value As Object)

Parameters

name
String

The name to associate with the value, so it can be deserialized later.

value
Object

The value to be serialized. Any children of this object will automatically be serialized.

Exceptions

name is null.

A value has already been associated with name.

Remarks

The object contained in the value parameter is serialized as the type returned by value.

If two values are added with names that differ only by case, no exception will be thrown, which is not a recommended practice. However, adding two values with the exact same name will cause the SerializationException to be thrown.

Applies to

AddValue(String, Int64)

Source:
SerializationInfo.cs
Source:
SerializationInfo.cs
Source:
SerializationInfo.cs

Adds a 64-bit signed integer value into the SerializationInfo store.

public:
 void AddValue(System::String ^ name, long value);
public void AddValue (string name, long value);
member this.AddValue : string * int64 -> unit
Public Sub AddValue (name As String, value As Long)

Parameters

name
String

The name to associate with the value, so it can be deserialized later.

value
Int64

The Int64 value to serialize.

Exceptions

The name parameter is null.

A value has already been associated with name.

Remarks

If two values are added with names that differ only by case, no exception will be thrown, which is not a recommended practice. However, adding two values with the exact same name will cause the SerializationException to be thrown.

Applies to

AddValue(String, Int32)

Source:
SerializationInfo.cs
Source:
SerializationInfo.cs
Source:
SerializationInfo.cs

Adds a 32-bit signed integer value into the SerializationInfo store.

public:
 void AddValue(System::String ^ name, int value);
public void AddValue (string name, int value);
member this.AddValue : string * int -> unit
Public Sub AddValue (name As String, value As Integer)

Parameters

name
String

The name to associate with the value, so it can be deserialized later.

value
Int32

The Int32 value to serialize.

Exceptions

The name parameter is null.

A value has already been associated with name.

Remarks

If two values are added with names that differ only by case, no exception will be thrown, which is not a recommended practice. However, adding two values with the exact same name will cause the SerializationException to be thrown.

Applies to

AddValue(String, Int16)

Source:
SerializationInfo.cs
Source:
SerializationInfo.cs
Source:
SerializationInfo.cs

Adds a 16-bit signed integer value into the SerializationInfo store.

public:
 void AddValue(System::String ^ name, short value);
public void AddValue (string name, short value);
member this.AddValue : string * int16 -> unit
Public Sub AddValue (name As String, value As Short)

Parameters

name
String

The name to associate with the value, so it can be deserialized later.

value
Int16

The Int16 value to serialize.

Exceptions

The name parameter is null.

A value has already been associated with name.

Remarks

If two values are added with names that differ only by case, no exception will be thrown, which is not a recommended practice. However, adding two values with the exact same name will cause the SerializationException to be thrown.

Applies to

AddValue(String, Double)

Source:
SerializationInfo.cs
Source:
SerializationInfo.cs
Source:
SerializationInfo.cs

Adds a double-precision floating-point value into the SerializationInfo store.

public:
 void AddValue(System::String ^ name, double value);
public void AddValue (string name, double value);
member this.AddValue : string * double -> unit
Public Sub AddValue (name As String, value As Double)

Parameters

name
String

The name to associate with the value, so it can be deserialized later.

value
Double

The double value to serialize.

Exceptions

The name parameter is null.

A value has already been associated with name.

Remarks

If two values are added with names that differ only by case, no exception will be thrown, which is not a recommended practice. However, adding two values with the exact same name will cause the SerializationException to be thrown.

Applies to

AddValue(String, Decimal)

Source:
SerializationInfo.cs
Source:
SerializationInfo.cs
Source:
SerializationInfo.cs

Adds a decimal value into the SerializationInfo store.

public:
 void AddValue(System::String ^ name, System::Decimal value);
public void AddValue (string name, decimal value);
member this.AddValue : string * decimal -> unit
Public Sub AddValue (name As String, value As Decimal)

Parameters

name
String

The name to associate with the value, so it can be deserialized later.

value
Decimal

The decimal value to serialize.

Exceptions

If The name parameter is null.

If a value has already been associated with name.

Remarks

If two values are added with names that differ only by case, no exception will be thrown, which is not a recommended practice. However, adding two values with the exact same name will cause the SerializationException to be thrown.

Applies to

AddValue(String, DateTime)

Source:
SerializationInfo.cs
Source:
SerializationInfo.cs
Source:
SerializationInfo.cs

Adds a DateTime value into the SerializationInfo store.

public:
 void AddValue(System::String ^ name, DateTime value);
public void AddValue (string name, DateTime value);
member this.AddValue : string * DateTime -> unit
Public Sub AddValue (name As String, value As DateTime)

Parameters

name
String

The name to associate with the value, so it can be deserialized later.

value
DateTime

The DateTime value to serialize.

Exceptions

The name parameter is null.

A value has already been associated with name.

Remarks

If two values are added with names that differ only by case, no exception will be thrown, which is not a recommended practice. However, adding two values with the exact same name will cause the SerializationException to be thrown.

Applies to

AddValue(String, Char)

Source:
SerializationInfo.cs
Source:
SerializationInfo.cs
Source:
SerializationInfo.cs

Adds a Unicode character value into the SerializationInfo store.

public:
 void AddValue(System::String ^ name, char value);
public void AddValue (string name, char value);
member this.AddValue : string * char -> unit
Public Sub AddValue (name As String, value As Char)

Parameters

name
String

The name to associate with the value, so it can be deserialized later.

value
Char

The character value to serialize.

Exceptions

The name parameter is null.

A value has already been associated with name.

Remarks

If two values are added with names that differ only by case, no exception will be thrown, which is not a recommended practice. However, adding two values with the exact same name will cause the SerializationException to be thrown.

Applies to

AddValue(String, Byte)

Source:
SerializationInfo.cs
Source:
SerializationInfo.cs
Source:
SerializationInfo.cs

Adds an 8-bit unsigned integer value into the SerializationInfo store.

public:
 void AddValue(System::String ^ name, System::Byte value);
public void AddValue (string name, byte value);
member this.AddValue : string * byte -> unit
Public Sub AddValue (name As String, value As Byte)

Parameters

name
String

The name to associate with the value, so it can be deserialized later.

value
Byte

The byte value to serialize.

Exceptions

The name parameter is null.

A value has already been associated with name.

Remarks

If two values are added with names that differ only by case, no exception will be thrown, which is not a recommended practice. However, adding two values with the exact same name will cause the SerializationException to be thrown.

Applies to

AddValue(String, Boolean)

Source:
SerializationInfo.cs
Source:
SerializationInfo.cs
Source:
SerializationInfo.cs

Adds a Boolean value into the SerializationInfo store.

public:
 void AddValue(System::String ^ name, bool value);
public void AddValue (string name, bool value);
member this.AddValue : string * bool -> unit
Public Sub AddValue (name As String, value As Boolean)

Parameters

name
String

The name to associate with the value, so it can be deserialized later.

value
Boolean

The Boolean value to serialize.

Exceptions

The name parameter is null.

A value has already been associated with name.

Remarks

If two values are added with names that differ only by case, no exception will be thrown, which is not a recommended practice. However, adding two values with the exact same name will cause the SerializationException to be thrown. For example:

void ISerializable.GetObject(SerializationInfo info, StreamingContext context)  
{  
   // This will not cause an exception to be thrown.  
   info.AddValue("ABC", true);  
   info.AddValue("abc", false);  
   // However, this will cause the SerializationException to be thrown.  
   info.AddValue("XYZ", true);  
   info.AddValue("XYZ", false);  
}  
Private Sub GetObjectData(ByVal info As SerializationInfo, _  
ByVal context As StreamingContext)  
   ' This will not cause an exception to be thrown.  
   info.AddValue("ABC", "upper case")  
   info.AddValue("abc", "lower case")  
   ' However, this will cause the SerializationException to be thrown.  
   info.AddValue("XYZ", "same case")  
   info.AddValue("XYZ", "same case")  
End Sub  

Applies to