Select - Indexed : Index : LINQ C# Source Code


Custom Search

C# Source Code » LINQ » Index »

 

Select - Indexed








    
 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass {
    public static void Main() {

        int[] numbers = { 5, 4, 1, 3, 9};

        var numsInPlace = numbers.Select((num, index) => new { Num = num, InPlace = (num == index) });

        foreach (var n in numsInPlace) {
            Console.WriteLine("{0}: {1}", n.Num, n.InPlace);
        }
    }
}

 
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo LINQ
» Index