linux-packaging-mono/mcs/tests/gtest-iter-03.cs
Jo Shields a575963da9 Imported Upstream version 3.6.0
Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
2014-08-13 10:39:27 +01:00

29 lines
526 B
C#

using System;
using System.Collections.Generic;
public class Test {
List<object> annotations = new List<object> ();
public IEnumerable<T> Annotations<T> () where T : class
{
foreach (T o in Annotations (typeof (T)))
yield return o;
}
public IEnumerable<object> Annotations (Type type)
{
if (annotations == null)
yield break;
foreach (object o in annotations)
if (o.GetType () == type)
yield return o;
}
public static void Main ()
{
var test = new Test ();
test.Annotations<Test> ();
}
}