[corlib] Make Marshal.BufferToBSTR(Array, int) non-public again (#5670)
[mono.git] / mcs / tests / test-anon-133.cs
1 using System;
2 using System.Collections.Generic;
3 using System.Text;
4
5 public static class IEnumerableRocks
6 {
7
8         public static string Implode<TSource, TResult> (this IEnumerable<TSource> self, string separator, Func<TSource, TResult> selector)
9         {
10                 return Implode (self, separator, (b, e) => { b.Append (selector (e).ToString ()); });
11         }
12
13         public static string Implode<TSource> (this IEnumerable<TSource> self, string separator, Action<StringBuilder, TSource> appender)
14         {
15                 var coll = self as ICollection<TSource>;
16                 if (coll != null && coll.Count == 0)
17                         return string.Empty;
18
19                 bool needSep = false;
20                 var s = new StringBuilder ();
21
22                 foreach (var element in self) {
23                         if (needSep && separator != null)
24                                 s.Append (separator);
25
26                         appender (s, element);
27                         needSep = true;
28                 }
29
30                 return s.ToString ();
31         }
32 }
33
34 class Test
35 {
36         public static void Main ()
37         {
38                 Console.WriteLine (new [] { "foo", "bar" }.Implode (", ", e => "'" + e + "'"));
39         }
40 }