Some query operators accept two input sequences.
Concat appends one sequence to another
Union does the same but with duplicates removed:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
class Program
{
static void Main()
{
int[] seq1 = { 1, 2, 3 };
int[] seq2 = { 3, 4, 5 };
IEnumerable concat = seq1.Concat(seq2); // { 1, 2, 3, 3, 4, 5 }
IEnumerable union = seq1.Union(seq2); // { 1, 2, 3, 4, 5 }
}
}
In query syntax
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
class Program
{
static void Main()
{
string[] names = { "C", "Java", "C#", "Javascript" };
IEnumerable query =
from n in names
where n.Contains("a") // Filter elements
orderby n.Length // Sort elements
select n.ToUpper(); // Translate each element (project)
foreach (string name in query)
Console.WriteLine(name);
}
}
The output:
JAVA
JAVASCRIPT