using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
public class MainClass{
public static void Main(string[] args){
String[] QueryString = { "One", "Two", "Three", "Four", "Five" };
var ThisQuery = from StringValue in QueryString
where StringValue.Length > 3
select StringValue + "\r\n";
// Display the result.
foreach (var ThisValue in ThisQuery){
Console.WriteLine(ThisValue);
}
}
}
static class MyWhere
{
public static IEnumerable<TSource> Where<TSource>(this IEnumerable<TSource> source, Func<TSource, bool> predicate)
{
int ThisCount = source.Count<TSource>();
TSource[] Results = new TSource[ThisCount];
Results.Initialize();
int ArrayCount = 0;
foreach (TSource ThisValue in source)
{
if (ThisValue.ToString().Length > 3)
{
Results[ArrayCount] = ThisValue;
ArrayCount++;
}
}
return Results;
}
}
|