Skip to content
Discussion options

You must be logged in to vote

This is not a compiler bug, but is how explicit conversions have been specified since C# version 1.

I'm a little confused about why the spec checks whether a standard implicit conversion (int to long) exists in reverse during an explicit conversion, rather than checking whether standard explicit conversions exist such as ulong to int. I'm curious if anyone has an intuition for what the spec is doing here.

(The spec does eventually, by implication, require the explicit conversion to also exist which matches the reverse implicit conversion, because the explicit conversion is what is performed if the matching reverse implicit conversion exists.)

Walkthrough

This is the reported sample:

public 

Replies: 6 comments 17 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@jilles-sg
Comment options

@RioMcBoo
Comment options

Comment options

You must be logged in to vote
7 replies
@RioMcBoo
Comment options

@RioMcBoo
Comment options

@jnm2
Comment options

jnm2 Nov 30, 2025
Collaborator

@RioMcBoo
Comment options

@jnm2
Comment options

jnm2 Nov 30, 2025
Collaborator

This comment was marked as off-topic.

@333fred

This comment was marked as off-topic.

Comment options

You must be logged in to vote
0 replies
Answer selected by jnm2
Comment options

You must be logged in to vote
7 replies
@RioMcBoo
Comment options

@AartBluestoke
Comment options

@RioMcBoo
Comment options

@RioMcBoo
Comment options

@jnm2
Comment options

jnm2 Dec 16, 2025
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
8 participants
Converted from issue

This discussion was converted from issue #8185 on June 11, 2024 15:59.