2010-05-19 Jb Evain <jbevain@novell.com>
[mcs.git] / tests / gtest-linq-08.cs
blob273145002235e95ffe54a81ffb7768f66178bed9
3 using System;
5 class TestA
7 public string value;
9 public TestA (string value)
11 this.value = value;
14 public string Select<U> (Func<TestA, U> f)
16 return value;
20 static class TestB
22 static public TestA Where(this TestA a, Func<TestA,bool> predicate)
24 if (predicate (a))
25 return new TestA ("where used");
27 return null;
31 public class CustomQueryExpressionPattern
33 static int Main ()
35 var v = new TestA ("Oh yes");
36 string foo = from a in v select a;
37 if (foo != "Oh yes")
38 return 1;
40 v = new TestA ("where?");
42 // It also tests that select is not called in this case
43 v = from a in v where a.value != "wrong" select a;
45 if (v.value != "where used")
46 return 1;
48 Console.WriteLine (v.value.ToString ());
49 return 0;