[C# Helper]
Index Books FAQ Contact About Rod
[Essential Algorithms, Second Edition]

[The Modern C# Challenge]

[WPF 3d, Three-Dimensional Graphics with WPF and C#]

[The C# Helper Top 100]

[Interview Puzzles Dissected]

[C# 24-Hour Trainer]

[Beginning Software Engineering]

[C# 5.0 Programmer's Reference]

[MCSD Certification Toolkit (Exam 70-483): Programming in C#]

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

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

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 the example to experiment with it and to see additional details.

© 2009-2022 Rocky Mountain Computer Consulting, Inc. All rights reserved.