Click here to Skip to main content
11,631,212 members (75,505 online)
Click here to Skip to main content
Add your own
alternative version

Poor Man's LINQ in Visual Studio 2005

, 28 Oct 2010 MIT 53K 526 34
A way to use LINQ to Objects in C# 2.0 with .NET Framework 2.0
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
			// 666
				.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.


This article, along with any associated source code and files, is licensed under The MIT License


About the Author

Software Developer Trapeze Software, Inc.
Canada Canada
Since I started programming when I was 11, I wrote the SNES emulator "SNEqr", the FastNav mapping component, and LLLPG, among other things. Now I'm old.

In my spare time I'm developing a system called Loyc (Language of your choice), which will include an enhanced C# compiler. Many programs have an add-in architecture; why not your programming language? I'm also looking for a life partner. Oh hi future wife! Wazzap.

You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.150723.1 | Last Updated 29 Oct 2010
Article Copyright 2008 by Qwertie
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid