Listing numbers 1 greater than each number in the list - CSharp LINQ

CSharp examples for LINQ:IEnumerable

Description

Listing numbers 1 greater than each number in the list

Demo Code



using System;//ww w . j a  va 2  s  .  co  m
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        List<int> numbers = new List<int>() { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 };
        int[] numArray = numbers.ToArray();
        List<string> words = new List<string> { "one", "two", "three", "four", "five" };

        numbers.ForEach(n => { Console.Write("{0}, ", Program.NumberAfterMeIs(n)); });

    }

    static int NumberAfterMeIs(int number)
    {
        return number + 1;
    }
}

Result


Related Tutorials