TimeZoneInfo.FromSerializedString Method (String)

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Deserializes a string to re-create an original serialized TimeZoneInfo object.

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

static member FromSerializedString : 
        source:string -> TimeZoneInfo

Parameters

source
Type: System.String

The string representation of the serialized TimeZoneInfo object.

Return Value

Type: System.TimeZoneInfo

The original serialized object.

Exception Condition
ArgumentException

The source parameter is String.Empty.

ArgumentNullException

The source parameter is a null string.

SerializationException

The source parameter cannot be deserialized back into a TimeZoneInfo object.

There is an alternative to providing all the code required to create a time zone that is not found in the registry. You can define a custom time zone and either use the ToSerializedString method in a standalone executable or use an application's setup program to save the time zone as a string. The application can then retrieve this string from its storage location and instantiate it using the FromSerializedString method.

The following example tries to retrieve the Antarctica/South Pole time zone from the local system. If it fails, the code tries to retrieve information about the time zone from a text file in the application directory. If this attempt fails, the code creates the time zone and writes information about the time zone to the text file.

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

.NET Framework
Available since 3.5
Return to top
Show: