2.Write a program in C# Sharp to find the positive numbers from a list of numbers using two where conditions in LINQ Query.
Expected Output:
The numbers within the range of 1 to 11 are :
1 3 6 9 10
using System;
using System.Collections.Generic;
using System.Linq;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
List<int> list = new List<int>() { 1, 3, 6, 9, 10,0, -1, -3, -6, -9, -10 };
IEnumerable<int> filteringQuery =
from num in list
where num >= 1 && num <= 11
select num;
foreach(int i in filteringQuery)
Console.Write(i+" ");
}
}
}
Comments
Leave a comment