DateTimeFormatInfo.ShortestDayNames Property

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Gets or sets a string array of the shortest unique abbreviated day names associated with the current DateTimeFormatInfo object.

Namespace: System.Globalization
Assembly: mscorlib (in mscorlib.dll)

Syntax

Public Property ShortestDayNames As String()
public string[] ShortestDayNames { get; set; }

Property Value

Type: array<System..::.String>[]()[]
A string array of day names.

Exceptions

Exception Condition
ArgumentException

An attempt was made to set the property to a multidimensional array or to a single-dimensional array with a length that is not exactly 7.

ArgumentNullException

In a set operation, the value array or one of the elements of the value array is nullNothingnullptra null reference (Nothing in Visual Basic).

InvalidOperationException

The DateTimeFormatInfo object is read-only.

Examples

The following example demonstrates several methods and properties that specify date and time format patterns, native calendar name, and full and abbreviated month and day names.


' This code example demonstrates the DateTimeFormatInfo 
' MonthGenitiveNames, AbbreviatedMonthGenitiveNames, 
' ShortestDayNames, and NativeCalendarName properties, and
' the GetShortestDayName() and SetAllDateTimePatterns() methods.

Imports System.Globalization

Class Example
   Public Shared Sub Demo(ByVal outputBlock As System.Windows.Controls.TextBlock)
      Dim name As String = ""

      ' Get the en-US culture.
      Dim ci As New CultureInfo("en-US")
      ' Get the DateTimeFormatInfo for the en-US culture.
      Dim dtfi As DateTimeFormatInfo = ci.DateTimeFormat

      ' Display the effective culture.
      outputBlock.Text &= String.Format("This code example uses the {0} culture.", _
                                        ci.Name) & vbCrLf

      ' Display month genitive names.
      outputBlock.Text &= vbCrLf & "MonthGenitiveNames..." & vbCrLf
      Dim monthNamesDisplay As String = ""
      For Each name In dtfi.MonthGenitiveNames
         If Not String.IsNullOrEmpty(monthNamesDisplay) Then _
            monthNamesDisplay &= ", "
         monthNamesDisplay &= String.Format("'{0}'", name)
      Next 
      outputBlock.Text &= monthNamesDisplay & vbCrLf & vbCrLf

      ' Display abbreviated month genitive names.
      monthNamesDisplay = ""
      outputBlock.Text &= vbCrLf & "AbbreviatedMonthGenitiveNames..." & vbCrLf
      For Each name In dtfi.AbbreviatedMonthGenitiveNames
         If Not String.IsNullOrEmpty(monthNamesDisplay) Then _
            monthNamesDisplay &= ", "
         monthNamesDisplay &= String.Format("'{0}'", name)
      Next 
      outputBlock.Text &= monthNamesDisplay & vbCrLf & vbCrLf

      ' Display shortest day names.
      outputBlock.Text &= vbCrLf & "ShortestDayNames..." & vbCrLf
      Dim dayNamesDisplay As String = ""
      For Each name In dtfi.ShortestDayNames
         If Not String.IsNullOrEmpty(dayNamesDisplay) Then _
            dayNamesDisplay &= ", "
         dayNamesDisplay &= String.Format("'{0}'", name)
      Next 
      outputBlock.Text &= dayNamesDisplay & vbCrLf & vbCrLf
   End Sub 
End Class 
' This code example produces the following results:
' 
' This code example uses the en-US culture.
' 
' MonthGenitiveNames...
' 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December', ''
' 
' AbbreviatedMonthGenitiveNames...
' 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec', ''
' 
' ShortestDayNames...
' 'Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'
// This example demonstrates the DateTimeFormatInfo 
// MonthGenitiveNames, AbbreviatedMonthGenitiveNames, 
// ShortestDayNames properties.
using System;
using System.Globalization;

class Example
{
   public static void Demo(System.Windows.Controls.TextBlock outputBlock)
   {
      string[] myDateTimePatterns = new string[] { "MM/dd/yy", "MM/dd/yyyy" };

      // Get the en-US culture.
      CultureInfo ci = new CultureInfo("en-US");
      // Get the DateTimeFormatInfo for the en-US culture.
      DateTimeFormatInfo dtfi = ci.DateTimeFormat;

      // Display the effective culture.
      outputBlock.Text += String.Format("This example uses the {0} culture.", 
                                        ci.Name) + "\n";

      // Display month genitive names.
      outputBlock.Text += "\nMonthGenitiveNames..." + "\n";
      string monthNamesDisplay = null;
      foreach (string name in dtfi.MonthGenitiveNames)
      {
         if (! String.IsNullOrEmpty(monthNamesDisplay))
            monthNamesDisplay += ", ";
         monthNamesDisplay += String.Format("'{0}'", name);
      }
      outputBlock.Text += monthNamesDisplay + "\n\n";

      // Display abbreviated month genitive names.
      monthNamesDisplay = "";
      outputBlock.Text += "\nAbbreviatedMonthGenitiveNames...\n";
      foreach (string name in dtfi.AbbreviatedMonthGenitiveNames)
      {
         if (! String.IsNullOrEmpty(monthNamesDisplay))
            monthNamesDisplay += ", ";
         monthNamesDisplay += String.Format("'{0}'", name);
      }
      outputBlock.Text += monthNamesDisplay + "\n\n";

      // Display shortest day names.
      string dayNamesDisplay = "";
      outputBlock.Text += "\nShortestDayNames...\n";
      foreach (string name in dtfi.ShortestDayNames)
      {
         if (! String.IsNullOrEmpty(dayNamesDisplay))
            dayNamesDisplay += ", ";
         dayNamesDisplay += String.Format("'{0}'", name);
      }
      outputBlock.Text += dayNamesDisplay + "\n\n";
   }
}
/*
This code example produces the following results:

This code example uses the en-US culture.

MonthGenitiveNames...
'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December', ''

AbbreviatedMonthGenitiveNames...
'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec', ''

ShortestDayNames...
'Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'
*/

Version Information

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Platforms

Windows Phone

See Also

Reference

DateTimeFormatInfo Class

System.Globalization Namespace