. Create a generic collection that stores even numbers from 2 to 20.
Display only the first element of the List.
using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
static void Main(string[] args)
{
List<int> numbers = new List<int>();
for (int i = 2; i <= 20; i++)
if (i % 2 == 0)
numbers.Add(i);
Console.WriteLine(numbers.First());
}
}
Comments
Leave a comment