Please note, this is a STATIC archive of website www.w3resource.com from 19 Jul 2022, cach3.com does not collect or store any user information, there is no "phishing" involved.
w3resource

C# Sharp Exercises: Display the name of the days of a week

C# Sharp LINQ : Exercise-6 with Solution

Write a program in C# Sharp to display the name of the days of a week.

Sample Solution:-

C# Sharp Code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
class LinqExercise6
    {
        static void Main(string[] args)
        {
            string[] dayWeek = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" };
			
            Console.Write("\nLINQ : Display the name of the days of a week : "); 
            Console.Write("\n------------------------------------------------\n");				
			
			
            var days = from WeekDay in dayWeek 
			           select WeekDay;
            foreach (var WeekDay in days)
            {
                Console.WriteLine(WeekDay);
            }
            Console.WriteLine();
        }
    }
	

Sample Output:

LINQ : Display the name of the days of a week :                                                               
------------------------------------------------                                                         
Sunday                                                                                                     
Monday                                                                                                     
Tuesday                                                                                                     
Wednesday                                                                                                     
Thursday                                                                                                     
Friday                                                                                                     
Saturday

Pictorial Presentation:

C# Sharp LINQ: Display the name of the days of a week.

Flowchart:

Flowchart: LINQ : Display the name of the days of a week

C# Sharp Code Editor:

Contribute your code and comments through Disqus.

Previous: Write a program in C# Sharp to display the characters and frequency of character from giving string.
Next: Write a program in C# Sharp to display numbers, multiplication of number with frequency and the frequency of number of giving array.

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.