A PHP Error was encountered

Severity: 8192

Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated

Filename: libraries/Filtered_db.php

Line Number: 23

Write a program in C# to create a list of numbers and display the numbers greater than 20 in LINQ Query
Q:

Write a program in C# to create a list of numbers and display the numbers greater than 20 in LINQ Query

0

Write a program in C# to create a list of numbers and display the numbers greater than 20 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.Collections.Generic;
using System.Linq;
using System.Text;
 
class LinqExercise
{
    static void Main(string[] args)
    {
 
        List<int> list = new List<int>();
        list.Add(10);
        list.Add(20);
        list.Add(30);
        list.Add(40);
        list.Add(90);
        list.Add(50);
        list.Add(70);
 
 
        Console.WriteLine("\nThe members of the list are : ");
        foreach (var lstnum in list)
        {
            Console.Write(lstnum + " ");
        }
        List<int> FilterList = list.FindAll(x => x > 20 ? true : false);
        Console.WriteLine("\n\nThe numbers greater than 20 are : ");
        foreach (var num in FilterList)
        {
            Console.WriteLine(num);
        }
        Console.ReadLine();
    }
}

Result:

The members of the list are : 

10 20 30 40 90 50 70 

The numbers greater than 20 are : 

30

40

90

50

70

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now