w3resource
C# Sharp Programming Exercises

C# Sharp Exercises: LINQ : 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

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?



New Content: Composer: Dependency manager for PHP, R Programming