C# program to find out Even/Odd numbers using OUT parameters

Rajnilari2015
Posted by Rajnilari2015 under C# category on | Points: 40 | Views : 139
The below program will do so

class MainClass
{
public static void Main(string[] args)
{
var evenNumList = new List<int>();
var oddNumList = new List<int>();

GetEvenOddNumbersUsingOutParameters(out evenNumList, out oddNumList);

}

private static void GetEvenOddNumbersUsingOutParameters(out List<int> evenNumList,
out List<int> oddNumList)
{
var numbers = Enumerable.Range(1, 20); //generate numbers between 1 to 20
evenNumList = numbers.Where(i => i % 2 == 0).ToList();
oddNumList = numbers.Where(i => i % 2 != 0).ToList();
}

}

Comments or Responses

Login to post response