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 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 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.
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.
Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.