DateTimeFormatInfo.YearMonthPattern Property
[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]
Gets or sets the custom date and time format string for a year and month value, which is associated with the "y" and "Y" standard format strings.
Assembly: mscorlib (in mscorlib.dll)
Property Value
Type: System.StringThe custom format string for a year and month value, which is associated with the "y" and "Y" format strings.
| Exception | Condition |
|---|---|
| ArgumentNullException | An attempt was made to set the property to Nothing. |
| InvalidOperationException | The DateTimeFormatInfo object is read-only. |
The following example displays the value of YearMonthPattern for a few cultures.
Imports System.Globalization Public Class Example Public Shared Sub Demo(ByVal outputBlock As System.Windows.Controls.TextBlock) ' Displays the values of the pattern properties. outputBlock.Text &= " CULTURE PROPERTY VALUE" & vbCrLf PrintPattern(outputBlock, "en-US") PrintPattern(outputBlock, "ar-EG") PrintPattern(outputBlock, "fr-FR") End Sub Public Shared Sub PrintPattern(ByVal outputBlock As System.Windows.Controls.TextBlock, ByVal myCulture As [String]) Dim myDTFI As DateTimeFormatInfo = New CultureInfo(myCulture).DateTimeFormat outputBlock.Text += String.Format(" {0} {1}", myCulture, myDTFI.YearMonthPattern) & vbCrLf End Sub End Class ' This example displays the following output: ' CULTURE PROPERTY VALUE ' en-US MMMM, yyyy ' ar-EG MMMM, yyyy ' fr-FR MMMM yyyy
Show: