1. Write a program in C# Sharp to show how the three parts of a query operation execute.
Expected Output:
The numbers which produce the remainder 0 after divided by 2 are :
0 2 4 6 8
using System;
using System.Collections.Generic;
using System.Linq;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
List<int> list = new List<int>() { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
IEnumerable<int> filteringQuery =
from num in list
where (num % 2) == 0
select num;
Console.WriteLine("The numbers which produce the remainder 0 after divided by 2 are:");
foreach (int i in filteringQuery)
Console.Write(i + " ");
}
}
}
Comments
Leave a comment