Skip to content

Instantly share code, notes, and snippets.

@gdyrrahitis

gdyrrahitis/boxing.cs Secret

Created Jun 21, 2019
Embed
What would you like to do?
public void BoxingUnboxing()
{
int x = 10;
double y = x; // This is fine
object o = x;
double z = (double)o; // Unhandled Exception: System.InvalidCastException:
// Unable to cast object of type 'System.Int32' to type 'System.Double'.
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.