Created
October 6, 2015 15:06
-
-
Save bfriesen/cc65f4cc7c113c882666 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Main() | |
{ | |
int barInt; | |
object barObj = Foo.GetBar(); | |
barInt = (int)barObj; // Success! | |
dynamic barDynamic = Foo.GetBar(); | |
barInt = (int)barDynamic; // RuntimeBinderException: Cannot convert type 'System.Enum' to 'int' | |
} | |
public class Foo | |
{ | |
public static object GetBar() | |
{ | |
return Bar.Baz; | |
} | |
private enum Bar | |
{ | |
Baz | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment