LINQ provides one of the easiest way to find out and filter the odd numbers from the List of Integers in C#.
The below sample code demonstrates the usage of the LINQ Query to achieve the same.
Filtering the Odd Numbers from the List of Integers using LINQ
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace GinktageConsole { class Program { static void Main(string[] args) { List<int> InputList = new List<int> { 24,25,26,11,23}; var OutPutItems = (from item in InputList where item % 2 != 0 select item).ToList<int>(); foreach (var OutputItem in OutPutItems) Console.WriteLine(OutputItem); Console.ReadLine(); } } }