Get the name of the first day of the week in C#

[first day of the week]

Different cultures start the week with a different first day of the week. For example, some cultures start the week with Monday and others start it with Sunday. Usually it doesn’t matter which day is the first day of the week, but if a program is drawing a calendar it will look more natural to the user if weeks start with the correct day.

The System.Globalization namespace’s CultureInfo.CurrentCulture.DateTimeFormat.DayNames value is an array holding the names of the days of the week for the computer’s locale. The first entry gives the name of the first day of the week.

This example uses the following code to display the name of the first day of the week.

lblResult.Text = "The first day of the week is " +
    CultureInfo.CurrentCulture.DateTimeFormat.DayNames[0];

That’s all there is to it. Of course if you are drawing a calendar, you’ll have more work to do.


Download Example   Follow me on Twitter   RSS feed   Donate




This entry was posted in internationalization, system and tagged , , , , , , , , , , , , , . Bookmark the permalink.

One Response to Get the name of the first day of the week in C#

  1. Pingback: Print a calendar in C# - C# HelperC# Helper

Leave a Reply

Your email address will not be published. Required fields are marked *