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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T08:22:59+00:00 2026-05-11T08:22:59+00:00

I have a routine public void SomeRoutine(List<IFormattable> list) { … } I then try

  • 0

I have a routine

public void SomeRoutine(List<IFormattable> list) { ... } 

I then try to call this routine

List<Guid>list = new List<Guid>(); list.Add(Guid.NewGuid()); SomeRoutine(list); 

And it fails with a compile-time error. System.Guid implements IFormattable, but the error I get is

cannot convert from ‘System.Collections.Generic.List’ to ‘System.Collections.Generic.List’

NOTE: You will get the same error if you just use an array of Guids. Generics is NOT the cause….

But! Given this

public void SomeRoutine2(IFormattable obj) { ... } 

and this

Guid a = Guid.NewGuid(); SomeRoutine2(a); 

It compiles! So the question is WHY? Why am I able to pass a Guid object (which implements IFormattable) into a routine that accepts an object of IFormattable, but when I try to expand that to a collection (a generic list, or an array, or anything else), I get a conversion error?

I have had a heck of a time finding an answer, and I figured this would be the best place to go.

  • 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-11T08:23:00+00:00Added an answer on May 11, 2026 at 8:23 am

    This is that whole covariance thing everyone talks about. It will work in .NET 4.0.

    See here: http://blogs.msdn.com/charlie/archive/2008/10/28/linq-farm-covariance-and-contravariance-in-visual-studio-2010.aspx

    Some more reading:

    http://www.infoq.com/news/2008/08/GenericVariance;jsessionid=188695B18864997E8D360E0EEED5983E

    http://blogs.msdn.com/lucian/archive/2008/10/02/co-and-contra-variance-how-do-i-convert-a-list-of-apple-into-a-list-of-fruit.aspx

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

Sidebar

Related Questions

I have this unit test: [Test] public void ProcessDbFile_should_delete_file_if_it_exists_then_copy_new_file_to_same_location() { // used to create
I have some CRUD routing: /news/{page} // public /news/new // private /news/{slug}/show //public /news/{slug}/edit
I have a routine that examines thousands of records looking for discrepancies. This can
I have a routine that dynamically changes a select list's selected option when the
So, I have a JTextPane co_LoggerEdit = new JTextPane(); co_LoggerEdit.setContentType(text/html); I then store the
I have a method which uses CyclicBarrier as shown below: public void getMessage(Message obj){
I have a problem in a WPF application. I wrote this code: public partial
I have a routine which is updating my business entity. The update involves about
I have a routine which uses a recursive loop to insert items into a
I have to design and implement a Fortran routine to determine the size of

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.