Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7060423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:21:04+00:00 2026-05-28T04:21:04+00:00

EDIT: It seems to be confirmed that covariant generics are not yet supported. To

  • 0

EDIT:
It seems to be confirmed that covariant generics are not yet supported. To make sure it makes it in the next release please email Xamarin and request this feature.

The following code gives me an error (at the linq statement). Identical code works fine in Microsoft clr c# 4.0.

Error:

Cannot implicitly convert type 'System.Collections.Generic.IEnumerable<LinqTest.Person>' to 'System.Collections.Generic.IEnumerable<LinqTest.Entity>'. An explicit conversion exists (are you missing a cast?)

Code:

[Activity(Label = "LinqTest", MainLauncher = true, Icon = "@drawable/icon")]
public class Activity1 : Activity {

    protected override void OnCreate(Bundle bundle) {
        base.OnCreate(bundle);

        var names = new List<string> {
                                         "Joe",
                                         "Bob",
                                         "Jim",
                                         "Jane"
                                     };

        IEnumerable<Entity> query =
            from e in names
            select new Person() {Name = e};

        SetContentView(Resource.Layout.Main);

        var button = FindViewById<Button>(Resource.Id.MyButton);

        button.Click += delegate {
                            button.Text = string.Format("{0}", query.Count());
                        };
    }
}

public class Entity {
    public string Name { get; set; }
}

public class Person : Entity {
    public string Workplace { get; set; }
}

public class Animal : Entity {
    public string FurColour { get; set; }
}

Am I correct or am I missing something? If so recommendations on refactoring this?

Also, if so, consider this an official feature request for monodroid – support for covariant generic support. 🙂

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T04:21:05+00:00Added an answer on May 28, 2026 at 4:21 am

    Neither MonoTouch nor Mono for Android has support for covariance right now. It will be supported in a future release (probably some time in the second half of this year).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Edit: [Solved] : It seems that the getTableCellRendererComponent of the CustomTableCellRenderer is called every
Which algorithms or data structures are used in auto-suggest features? It seems that edit-distance
EDIT : I completely re-wrote the question since it seems like I was not
PLEASE SEE THE EDIT BELOW, THE REPORT SEEMS TO USE CACHED DATA? I cant
I have an Edit button next to each uploaded thumbnail on my page that
EDIT 2: Confirmed that my performance problems were due to the static function call
[edit] So it seems my code works fine, another piece of code + tiredness
It seems it allows you to edit the content of an element, but what
[EDIT] Based on feedback yes, VS2010 seems to support SL4 Library TDD despite a
This seems like such a simple question. I have several Edit boxes on my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.