Link two array in LINQ statement in CSharp

Description

The following code shows how to link two array in LINQ statement.

Example


   //from w w w.  j  av a 2 s. co m
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 textNums =
            from n in numbers
            select strings[n];

        Console.WriteLine("Number strings:");
        foreach (var s in textNums) {
            Console.WriteLine(s);
        }
    }
}




















Home »
  C# Tutorial »
    LINQ »




Operator
Select
Where
OrderBy
Group
Join
Let
LINQ