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

  • Home
  • SEARCH
  • 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 167647
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T12:18:45+00:00 2026-05-11T12:18:45+00:00

Can someone explain to me why in .NET 2.0 if I have an interface,

  • 0

Can someone explain to me why in .NET 2.0 if I have an interface, IPackable and a class that implements that interface OrderItem, when I have a method that takes in a List<IPackable>, passing in a list of List<OrderItem> does not work?

Does anyone know how I could accomplish this functionality?

Code:

public interface IPackable {         double Weight{ get; } }  public class OrderItem : IPackable   public List<IShipMethod> GetForShipWeight(List<IPackable> packages) {    double totalWeight = 0;    foreach (IPackable package in packages) {         totalWeight += package.Weight;    } } 

The following code does not work.

List<OrderItem> orderItems = new List<OrderItem>(); List<IShipMethod> shipMethods = GetForShipWeight(orderItems); 
  • 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. 2026-05-11T12:18:45+00:00Added an answer on May 11, 2026 at 12:18 pm

    The feature is called covariance/contravariance and will be supported in c# 4.0. You can read about it here: http://blogs.msdn.com/ericlippert/archive/tags/Covariance+and+Contravariance/default.aspx

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

Sidebar

Related Questions

I have a very simple app on my local machine that uses the ASP.NET
I have a Visual Studio 2010 project targeting .NET Framework 4.0. When I add
I have an ASP.NET Web Application which has a reference to 'C:\references\Utils.Varia.dll'. There is
I was reading Scott Guthrie blog and i have encounter a sample. You can
I have used a lot of abstract classes both for polymorphism, and obviously inheriting
Reading Guru-Gu's blog post about ASP.NET MVC3 hitting RC , he says:- Session-less Controller
I'm migrating my solutions from .NET 2.0 to .NET 4.0. I open the solution
I'm migrating my solutions from .NET 2.0 to .NET 4.0. I open the solution
I just shoot myself in the foot and would like to know whether there
Per a conversation with @Aaronaught on another thread, I've started converting my application to

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.