You can use one of the Linq extension methods to work around this:

public interface IBase { }
public interface IChild : IBase { }

public IEnumerable<IBase> Tst()
{
    var result = new List<IChild>();
    return result.Cast<IBase>();
}

--
Adam Kemp
[email protected]
(512) 683-6058

[email protected] wrote on 11/04/2012 02:17:21 AM:

> From: Artur Drobinskiy <[email protected]>
> To: monotouch <[email protected]>, 
> Date: 11/04/2012 02:17 AM
> Subject: [MonoTouch] Implicit type conversion from List<T> to 
> IEnumerable<TBase>
> Sent by: [email protected]
> 
> The following code compiles well on win platform, but causing 
> "Cannot implicitly convert type List<IChild> to IEnumerable<IBase>" 
> compilation error on MT:
> 
> public interface IBase { }
> public interface IChild : IBase { }
> 
> public IEnumerable<IBase> Tst()
> {
>     var result = new List<IChild>();
>     return result;
> }
> 
> I've googled for it, and it doesn't seem like a well-known problem. 
> 
> Am I doing something wrong and that should work?
> Is result.Cast<IBase>() the best solution for that case?
> 
> Thanks!_______________________________________________
> MonoTouch mailing list
> [email protected]
> http://lists.ximian.com/mailman/listinfo/monotouch

_______________________________________________
MonoTouch mailing list
[email protected]
http://lists.ximian.com/mailman/listinfo/monotouch

Reply via email to