DateTimeFormatInfo.GetAllDateTimePatterns Method (Char)
Returns all the patterns in which date and time values can be formatted using the specified standard format string.
Assembly: mscorlib (in mscorlib.dll)
This method returns an array containing the custom format strings that correspond to a particular standard format string. See Standard Date and Time Format Strings for a list of the standard format strings.
You can use the custom format strings in the array returned by the GetAllDateTimePatterns method can be used to round-trip date and time values. The following example illustrates this problem. It retrieves a DateTimeFormatInfo object that contains formatting information for the Russia (Russian) culture. It calls the method for each standard format string, and then passes each custom format string in the returned array to the DateTime.ToString(String) method to create the string representation of a date and time. This example then attempts to parse this value by calling the DateTime.TryParse(String, DateTime) method. As the output from the example shows, some of the custom format strings do not produce a date and time value that successfully round-trips.method in formatting operations. However, if you do, the string representation of a date and time value returned in that formatting operation cannot always be parsed successfully by the Parse and TryParse methods. Therefore, you cannot assume that the custom format strings returned by the
To parse the string representation of a date and time that can be expressed in a number of predefined custom formats, call one of the following methods:
The custom format strings in the array returned by the GetAllDateTimePatterns method depends on the current calendar of the culture for which the DateTimeFormatInfo object supplies formatting information. If the calendar changes, the array returned by this method also changes.
Available since 1.1