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 8367515
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T13:10:45+00:00 2026-06-09T13:10:45+00:00

Exact code I’m trying to build: public interface IMapContainer<out T> where T : MapRoomBase

  • 0

Exact code I’m trying to build:

    public interface IMapContainer<out T> where T : MapRoomBase
    {
        String GetName();

        IEnumerable<T> GetRooms();
    }

I’m getting this error:
Invalid variance: The type parameter ‘T’ must be invariantly valid on ‘MapLibrary.IMapContainer.GetRooms()’. ‘T’ is covariant.

I was under the impression that this would be valid since IEnumerable simply returns the items, and none can be added. Why is this not safe + valid?

  • 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-06-09T13:10:47+00:00Added an answer on June 9, 2026 at 1:10 pm

    Make sure you’re not targeting an old framework version. IEnumerable<T> is covariant starting with .NET 4. Your code compiles fine under .NET 4 and fails with the error you mention on .NET 3.5.

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

Sidebar

Related Questions

a more exact version of the code is: class SomeParam; class IBase { public:
I cannot convert JS object to exact string, my code: jsonObj['payment_value']=100.10; jsonObj['payment_date']=2012-06-15; jsonObjStr =
I've got this setup in my code: public abstract class ModelBase{} public interface IModelbase<T>{}
This is my exact SQL code, but it's very slow and I know it's
Somehow my code doesn't work any more (it did work before with the exact
What is the exact way of generating a Java code using WSDL in a
The applicable code is below, as is the exact error. sd = socket(AF_INET, SOCK_RAW,
I am not sure about the exact purpose of the following Rampion's code .
I dont know the exact code i need to retrieve all of the filenames
I have two sites using the same exact code for @font-face. The font files

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.