Select with Anonymous Types : select : LINQ C# Source Code


Custom Search

C# Source Code » LINQ » select »

 

Select with Anonymous Types








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

public class MainClass {
    public static void Main() {

        int[] numbers = { 5, 4, 1};
        string[] strings = { "zero", "one", "two"};

        var digitOddEvens =
            from n in numbers
            select new { Digit = strings[n], Even = (n % 2 == 0) };

        foreach (var d in digitOddEvens) {
            Console.WriteLine("The digit {0} is {1}.", d.Digit, d.Even ? "even" : "odd");
        }
    }
}

 
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo LINQ
» select