Make StringComparer.Create throw ArgumentNullException (#26570)
[mono-project.git] / mcs / tests / gtest-iter-33.cs
blobbc86539667963e561dce021a9310bafb590c0175
1 using System;
2 using System.Collections.Generic;
4 public delegate R Fun<A1,R>(A1 x);
6 class MyTest {
7 public static void Main(String[] args) {
8 foreach (Object d in Map<int,int,String,Object>
9 (delegate (int x) { return x.ToString(); },
10 FromTo(10,20)))
11 Console.WriteLine(d);
14 // Map with argument/result co/contravariance:
15 // Aa=argument, Rr=result, Af=f's argument, Rf=f's result
17 public static IEnumerable<Rr> Map<Aa,Af,Rf,Rr>(Fun<Af,Rf> f,
18 IEnumerable<Aa> xs)
19 where Aa : Af
20 where Rf : Rr
22 foreach (Aa x in xs)
23 yield return f(x); // gmcs 1.1.9 bug: cannot convert Aa to Af
26 // FromTo : int * int -> int stream
28 public static IEnumerable<int> FromTo(int from, int to) {
29 for (int i=from; i<=to; i++)
30 yield return i;