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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T18:47:51+00:00 2026-05-16T18:47:51+00:00

What does From any class-type S to any interface-type T, provided S is not

  • 0

What does “From any class-type S to any interface-type T, provided S is not sealed and provided S does not implement T.” actually mean?

I came across this in the C# Language Specifications here:

6.2.4 Explicit reference conversions

The explicit reference conversions
are:

  • …
  • From any class-type S to any interface-type T, provided S is not
    sealed and provided S does not
    implement T.

I can understand what “provided S is not sealed” means, but I’m not sure if I understand what “provided S does not implement T” really mean.

For example:

class S {}//not sealed, nor does it implement T
interface T {}
...
T t = (T)new S();//will throw InvalidCastException.

Could it be that it is in the specs only to enumerate all syntactically correct ways of expressing an explicit reference conversion, regardless of whether it will throw an exception or not? Or does it mean some other thing which I do not know (as of now)?

Thanks in advance.

  • 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-16T18:47:51+00:00Added an answer on May 16, 2026 at 6:47 pm

    The pun is in the “not sealed” part:

    class S {} //not sealed, nor does it implement T
    interface T {}
    
    class S2 : S, T { }
    
      S s = new S2();   // S reference to an S2 instance, implicit conversion
      T t = (T)s;       // OK, s refers to an S2 instance that does implement T
    

    Could it be that it is in the specs only to enumerate all syntactically correct ways of expressing an explicit reference conversion, …

    Yes, the compiler must allow it unless it knows the conversion to be impossible.

    If you look at T t = (T)s;, if S was sealed then the compiler could know with certainty that the conversion was impossible. But with an unsealed S, it would have to eliminate the possibility that s is referencing an S2 type, and that is not practical/possible (S2 could be in another assembly).

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

Sidebar

Related Questions

I came across following code and don't know what does having from twice mean
Does anyone have any experiences from recent daily build of AnkhSVN? Please let me
Does anyone have any experience with doing mail merge from Java on a word
Does anyone of you have any experience with switching from SQL Server 2008 to
Does anybody have any experience with as3-spod? I downloaded the source code from github
Does anyone know of any good websites on the upcoming Grand Central technology from
Does (int)myDouble ever differ from (int)Math.Truncate(myDouble) ? Is there any reason I should prefer
I need to archive data from a CRM system. Does anyone have any idea
I have a number of class, all with exactly the same interface. This interface
I've implemented a class that looks like this interface: [ImmutableObject(true)] public interface ICustomEvent {

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.