DateTimeFormatInfo.MonthDayPattern Właściwość

Definicja

Pobiera lub ustawia ciąg formatu niestandardowego dla wartości miesiąca i dnia.

public:
 property System::String ^ MonthDayPattern { System::String ^ get(); void set(System::String ^ value); };
public string MonthDayPattern { get; set; }
member this.MonthDayPattern : string with get, set
Public Property MonthDayPattern As String

Wartość właściwości

String

Ciąg formatu niestandardowego dla wartości miesiąca i dnia.

Wyjątki

Właściwość jest ustawiana na null wartość .

Właściwość jest ustawiana, a DateTimeFormatInfo obiekt jest tylko do odczytu.

Przykłady

W poniższym przykładzie jest MonthDayPattern wyświetlana wartość kilku kultur.

using namespace System;
using namespace System::Globalization;
void PrintPattern( String^ myCulture )
{
   CultureInfo^ MyCI = gcnew CultureInfo( myCulture,false );
   DateTimeFormatInfo^ myDTFI = MyCI->DateTimeFormat;
   Console::WriteLine( " {0} {1}", myCulture, myDTFI->MonthDayPattern );
}

int main()
{
   
   // Displays the values of the pattern properties.
   Console::WriteLine( " CULTURE    PROPERTY VALUE" );
   PrintPattern( "en-US" );
   PrintPattern( "ja-JP" );
   PrintPattern( "fr-FR" );
}

/*
This code produces the following output.  The question marks take the place of native script characters.

CULTURE    PROPERTY VALUE
en-US     MMMM dd
ja-JP     M'?'d'?'
fr-FR     d MMMM

*/
using System;
using System.Globalization;

public class SamplesDTFI  {

   public static void Main()  {

      // Displays the values of the pattern properties.
      Console.WriteLine( " CULTURE    PROPERTY VALUE" );
      PrintPattern( "en-US" );
      PrintPattern( "ja-JP" );
      PrintPattern( "fr-FR" );
   }

   public static void PrintPattern( String myCulture )  {

      DateTimeFormatInfo myDTFI = new CultureInfo( myCulture, false ).DateTimeFormat;
      Console.WriteLine( "  {0}     {1}", myCulture, myDTFI.MonthDayPattern );
   }
}

/*
This code produces the following output.  The question marks take the place of native script characters.

 CULTURE    PROPERTY VALUE
  en-US     MMMM dd
  ja-JP     M'?'d'?'
  fr-FR     d MMMM

*/
Imports System.Globalization

Public Class SamplesDTFI

   Public Shared Sub Main()

      ' Displays the values of the pattern properties.
      Console.WriteLine(" CULTURE    PROPERTY VALUE")
      PrintPattern("en-US")
      PrintPattern("ja-JP")
      PrintPattern("fr-FR")

   End Sub

   Public Shared Sub PrintPattern(myCulture As [String])

      Dim myDTFI As DateTimeFormatInfo = New CultureInfo(myCulture, False).DateTimeFormat
      Console.WriteLine("  {0}     {1}", myCulture, myDTFI.MonthDayPattern)

   End Sub

End Class

'This code produces the following output.  The question marks take the place of native script characters.
'
' CULTURE    PROPERTY VALUE
'  en-US     MMMM dd
'  ja-JP     M'?'d'?'
'  fr-FR     d MMMM
'

Uwagi

Właściwość definiuje specyficzny dla kultury format ciągów daty, które są zwracane przez wywołania metod i oraz złożone ciągi formatu, które są dostarczane ze standardowymi ciągami formatu MonthDayPattern DateTime.ToString "m" i DateTimeOffset.ToString "M".

Zmiana wartości właściwości ma wpływ na Calendar tę właściwość.

Zalecamy ustawienie separatora daty we wzorcu miesiąca i dnia na dokładny ciąg zamiast używania symbolu zastępczego separatora daty. Aby na przykład uzyskać wzorzec MM-DD, ustaw wzorzec miesiąca i dnia na wartość "MM-DD".

Dotyczy

Zobacz też