Q:

Write a program in C# to display the name of the days of a week in LINQ Query

belongs to collection: All LINQ programs in C# with examples

0

Write a program in C# to display the name of the days of a week in LINQ Query

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

I have used Visual Studio 2012 for debugging purpose. But you can use any version of visul studio as per your availability.

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

Result:

Days of a week

Sunday

Monday

Tuesday

Wednesday

Thursday

Friday

Saturday

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Write a program in C# to create a list of numbers ... >>
<< Write a program in C# to find the positive numbers...