Linq-produce a sequence of ints one higher than those in an existing array of ints.

This Function show you  how to  to select   ints one higher than those in an existing array of ints.

public void LinqDemo()
        {
            int[] numbers = { 2,5,7,3,1,8,9,2};

            var numsPlusOne =
                from n in numbers
                select n + 1;

            Console.WriteLine("Numbers + 1:");
            foreach (var i in numsPlusOne)
            {
                Console.WriteLine(i);
            }
      }



OutPut:


Numbers + 1:
3
6
8
4
2
9
10
3
Ebook Download
View all
Learn
View all