Note that there are some explanatory texts on larger screens.

plurals
  1. POSilverlight 4.0 lacks C# 4.0 language support?
    text
    copied!<p>The below code compiles with .Net Framework 4.0 but not with Silverlight 4.0. I would appreciate if anyone could shed some light on this. Here're the error messages I'm getting:</p> <pre><code>Error 1 The best overloaded method match for 'ThinkFarAhead.Confounded.Client.Models.Consumer.SetFunctionalAreas(System.Collections.Generic.IEnumerable&lt;ThinkFarAhead.Confounded.Client.Models.IFunctionalArea&gt;)' has some invalid arguments c:\Hanu\SilverlightApplication1\Test.cs 64 13 SilverlightApplication1 Error 3 The best overloaded method match for 'ThinkFarAhead.Confounded.Client.Models.Consumer.SetFunctionalAreas(System.Collections.Generic.IEnumerable&lt;ThinkFarAhead.Confounded.Client.Models.IFunctionalArea&gt;)' has some invalid arguments c:\Hanu\SilverlightApplication1\Test.cs 65 13 SilverlightApplication1 Error 2 Argument 1: cannot convert from 'ThinkFarAhead.Confounded.Web.EntitySet&lt;ThinkFarAhead.Confounded.Web.FunctionalArea&gt;' to 'System.Collections.Generic.IEnumerable&lt;ThinkFarAhead.Confounded.Client.Models.IFunctionalArea&gt;' c:\Hanu\SilverlightApplication1\Test.cs 64 47 SilverlightApplication1 Error 4 Argument 1: cannot convert from 'ThinkFarAhead.Confounded.Web.EntitySet&lt;ThinkFarAhead.Confounded.Web.FunctionalArea&gt;' to 'System.Collections.Generic.IEnumerable&lt;ThinkFarAhead.Confounded.Client.Models.IFunctionalArea&gt;' c:\Hanu\SilverlightApplication1\Test.cs 65 47 SilverlightApplication1 </code></pre> <p>What I'm trying to do: Extend generated entities (RIA) on Silverlight (4.0) side to make multiple entities with common features share the same interface (A control needs to use multiple objects the same way. These objects are pretty much the same).</p> <p>Thanks in advance.</p> <pre><code>using System; using System.Collections; using System.Collections.Generic; using ThinkFarAhead.Confounded.Client.Models; using ThinkFarAhead.Confounded.Web; namespace ThinkFarAhead.Confounded.Web { public class Entity { } public class EntitySet&lt;T&gt; : IEnumerable&lt;T&gt;, IEnumerable where T : Entity { List&lt;T&gt; list = new List&lt;T&gt;(); public IEnumerator&lt;T&gt; GetEnumerator() { return (IEnumerator&lt;T&gt;)list; } IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); } public void Add(T newone) { list.Add(newone); } } public partial class FunctionalArea : Entity { public string Name { get; set; } } public partial class FunctionalArea : IFunctionalArea { } } namespace ThinkFarAhead.Confounded.Client.Models { public interface IFunctionalArea { string Name { get; set; } } public class Variance { public static EntitySet&lt;FunctionalArea&gt; FunctionalAreas { get { return new EntitySet&lt;FunctionalArea&gt;(); } } public static void Main() { var abc = new EntitySet&lt;FunctionalArea&gt;(); new Consumer().SetFunctionalAreas(abc); new Consumer().SetFunctionalAreas(FunctionalAreas); } } public class Consumer { public void SetFunctionalAreas(IEnumerable&lt;IFunctionalArea&gt; areas) { } } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload