A simple example that allows you to read data from an array using C# and LINQ
A simple example that allows you to read data from an array, perform a query, and apply an order, using C# and LINQ.
Code:
using System;
using System.Linq;
using System.Xml.Linq;
namespace ConsoleApplications
{
class TestLinqInCSharp
{
static void Main(string[] args)
{
string[] customers = { "Arianne",
"Bill",
"David",
"Manuel",
"Veronic",
"Asia",
"Daniel",
"Renate",
"Vincent",
"Alexia",
"Daisy"};
var nameQuery =
from name in customers
where (name.Length > 5)
orderby name descending
select name;
foreach (string n in nameQuery)
Console.WriteLine("{0}", n);
}
}
}
Result:
Vincent
Veronic
Renate
Manuel
Daniel
Arianne
Alexia