Skip to content

Instantly share code, notes, and snippets.

@bfriesen
Created October 6, 2015 15:06
Show Gist options
  • Save bfriesen/cc65f4cc7c113c882666 to your computer and use it in GitHub Desktop.
Save bfriesen/cc65f4cc7c113c882666 to your computer and use it in GitHub Desktop.
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