Write a program in C# to find the positive numbers from a list of numbers using two where conditions 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.

using System;
using System.Linq;
 
class LinqExercise
{
    static void Main()
    {
        int[] numbers = {  
                1, 3, 6, 9, 10, -4, -2, -3, -88, 12, 19,  14  
            };
 
        var nQuery =
        from VrNum in numbers
        where VrNum > 0
        where VrNum < 10
        select VrNum;
        Console.Write("\nThe numbers within the range of 1 to 10 are : \n");
        foreach (var VrNum in nQuery)
        {
            Console.Write("{0}  ", VrNum);
        }
        Console.ReadLine();
    }
}

Result

Write a program in C# to find the positive numbers from a list of numbers using two where conditions in LINQ Query
Write a program in C# to find the positive numbers from a list of numbers using two where conditions in LINQ Query

Leave a Comment