class Sample
shared
def main
Sample.foo = @[Bar(), Bar()]
print Sample.foo
var foo as IFoo*?
interface IFoo
pass
class Bar
implements IFoo
pass
the following c# sample works ok, and c# 4 supports co-contra variance
- Code: Select all
using System;
using System.Collections.Generic;
public class Sample{
public static void Main(){
foo = new[] {new Bar{}, new Bar{}};
Console.WriteLine(foo);
}
static IEnumerable<IFoo> foo;
}
interface IFoo{}
class Bar : IFoo{}
I'm not sure of the implications for other backends or implementation, but for csharp it seems to be the right thing to do