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


Introduction

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


techstudy.org

HP 15 Core i3 7th gen Laptop(4GB, 1TB HDD, Windows 10) | Rs. 31,490

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. class LinqExercise
  7. {
  8. static void Main(string[] args)
  9. {
  10. string[] dayWeek = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" };
  11.  
  12. var days = from WeekDay in dayWeek
  13. select WeekDay;
  14. Console.WriteLine("Days of a week\n");
  15. foreach (var WeekDay in days)
  16. {
  17. Console.WriteLine(WeekDay);
  18. }
  19. Console.ReadLine();
  20. }
  21. }

Result

C# language techstudy.org

     





Related Topics




Popular Posts