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 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 found this example on StackOverflow: var people = new List<Person> { new
I have this routine that calculates the seconds-to-date for a struct tm . On
I have a method which uses CyclicBarrier as shown below: public void getMessage(Message obj){
I foolishly decided to try something new on a Friday job! So I have
I have a class with two methods defined in it. public class Routines {
I need to have a routine/function/stored proc/whatever to archive particular accounts from our 'active'
I have a little routine that's run under Linux and Windows written in C
I have a javascript routine that is performing actions on a group of checkboxes,
Do you have a simple debounce routine handy to deal with a single switch
If I have the following code: [TestFixture] public class MyBaseTest { protected ISessionManager _sessionManager;

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.