CSharp examples for Language Basics:switch
Switch on day of the week
using System;//from w w w. j av a2 s . com using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; class Program { static void Main(string[] args) { // Input Console.Write("Enter a date: "); string input = Console.ReadLine(); DateTime enteredDate = Convert.ToDateTime(input); // Finding day of week (in enumeration) DayOfWeek dayOfWeek = enteredDate.DayOfWeek; // Spanish texts string spanish = ""; switch (dayOfWeek) { case DayOfWeek.Monday: spanish = "Lunes"; break; case DayOfWeek.Tuesday: spanish = "Martes"; break; case DayOfWeek.Wednesday: spanish = "Miercoles"; break; case DayOfWeek.Thursday: spanish = "Jueves"; break; case DayOfWeek.Friday: spanish = "Viernes"; break; case DayOfWeek.Saturday: spanish = "Sebado"; break; case DayOfWeek.Sunday: spanish = "Domingo"; break; } } }