Q:

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

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

0

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

The numbers within the range of 1 to 10 are : 

1  3  6  9

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 display the name of the d... >>