// Collection of code snippets by Arne Vajhøj // (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) using System; public class P { public void M() { Console.WriteLine("M here"); } } public class C : P { } public interface IFoobar { T GetOne(); } public class Foobar : IFoobar where T : new() { public T GetOne() { return new T(); } } public class Program { public static void Main(String[] args) { IFoobar

fb = new Foobar(); // compile error IFoobar

fb = (IFoobar

)new Foobar(); // runtime error P o = fb.GetOne(); o.M(); } }