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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T02:54:07+00:00 2026-05-14T02:54:07+00:00

If I make an empty test class: public class Foo { } And I

  • 0

If I make an empty test class:

public class Foo
{
}

And I try to compile code with this statement:

Foo foo = "test";

Then I get this error as expected:

Cannot implicitly convert type ‘string’ to ‘ConsoleApplication1.Foo’

However, if I change the declaration of Foo from class to interface, the error changes to this (emphasis mine):

Cannot implicitly convert type
‘string’ to ‘ConsoleApplication1.Foo’.
An explicit conversion exists (are you
missing a cast?)

What is this “explicit conversion” which is supposed to exist?

update: the issue is a bit more subtle than I initially thought. To reproduce it, put this code in a new console application in Visual Studio 2008:

namespace ConsoleApplication1
{
    class Foo
    {
    }

    interface IFoo
    {
    }


   class Program
   {
      static void Main(string[] args)
      {
         Foo b = "hello";
      }
   }
}

Visual studio will automatically show the correct error at this point (before you build the code). Now insert the “I” to turn “Foo” into “IFoo” and wait a few seconds without building. The “explicit conversion exists” version of the error will now appear automatically in the error output window and in the tool tip for the assignment error.

The erroneous error then disappears again when you explicitly hit F6 to build.

  • 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-14T02:54:08+00:00Added an answer on May 14, 2026 at 2:54 am

    I am unable to reproduce the reported behaviour. If it does in fact reproduce, that’s a bug. There is no explicit conversion from string to any user-defined interface.

    Please update the question with the version number of the compiler you’re using and a small program that reproduces the problem, and I’ll get a bug entered into the bug database.

    Thanks!

    UPDATE: Apparently it does not reproduce on the command line, but is alleged to reproduce in VS2008.

    I am unable to reproduce it in the RC build of VS2010, so if this was in fact a bug in VS2008, it’s probably been fixed. I don’t have an installation of VS2008 handy right now to test unfortunately.

    Regardless, if you’re seeing that diagnostic then odds are very good it is simply a bug in the error reporting heuristics in the semantic analyzer. Clearly there is no explicit conversion from string to IFoo.

    There is an explicit conversion from any unsealed type to any interface type because there could be a derived type which implements the interface. But string is sealed, so the error should simply be “no conversion”.

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

Sidebar

Related Questions

I have something like this public class ViewModel { public List<Books> Test {get; set;}
In C#, if you do this, it will compile: namespace Name { public class
I have this class: public class TestClass { public TestClass(int? foo, string bar) {
i want to make empty textbox checking for android. i tried try catch but
I want to declare an empty list inside a scheme function. To make this
i make one class file for jar. and this class have use wurfl. and
I'm using this method when file is loaded: $(<script/>, { class: test, src: 'http://www.externalSite.com/js/xxx.js'
I have simple controller: public class TestController : Controller { public ActionResult Test(string r)
I have a Repositry class wich initiates like this: public ContactRepository(string sqlStr, string username)
I have some Scala code I cannot get to compile, and I simplified it

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.