|
using System;
using System.Collections.Generic;
using System.Text;
using Compatibility.Linq;
namespace Demo
{
class Program
{
public static PoorMansLinq<T> Linq<T>(IEnumerable<T> source)
{
return new PoorMansLinq<T>(source);
}
public static void Main(string[] args)
{
string[] words = new string[] { "Pies", "Are", "Good", "In", "Lovely", "Apples" };
// Pies Are Good
Console.WriteLine(string.Join(" ", Linq(words).Take(3).ToArray()));
// Apples Are Good In Lovely Pies
Console.WriteLine(string.Join(" ", Linq(words).Sorted().ToArray()));
int[] numbers = new int[] { 4, 95, 309, 357, 233, 2 };
// 1000
Console.WriteLine(Enumerable.Sum(numbers));
// 666
Console.WriteLine(Enumerable.Sum(Linq(numbers)
.Where(delegate(int x) { return x > 300; })));
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.