System.Globalization.DateTimeFormatInfo.YearMonthPattern Property

Gets or sets the custom format string for a year and month value.

Syntax

public string YearMonthPattern { get; set; }

Value

The format pattern for a year and month value.

Exceptions

TypeReason
ArgumentNullExceptionThe value specified for a set operation is a null reference.
InvalidOperationExceptionThe current instance is read-only and a set operation was attempted.

Remarks

The DateTimeFormatInfo.YearMonthPattern property defines the culture-specific format of date strings that are returned by calls to the DateTime.ToString and DateTimeOffset.ToString methods and by composite format strings that are supplied the "y" and "Y" standard format strings.

This property is affected if the value of the DateTimeFormatInfo.Calendar property changes.

We recommend that you set the date separator in the year month pattern to an exact string instead of using the date separator placeholder. For example, to get the pattern MM-yyyy, set the year month pattern to "MM-yyyy".

Requirements

Namespace: System.Globalization
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0