Created
September 6, 2015 09:54
-
-
Save angelovstanton/306098ad12c7d5c476b9 to your computer and use it in GitHub Desktop.
This file contains 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
dynamic dynamicVariable; | |
int i = 20; | |
dynamicVariable = (dynamic)i; | |
Console.WriteLine(dynamicVariable); | |
string stringVariable = "Example string."; | |
dynamicVariable = (dynamic)stringVariable; | |
Console.WriteLine(dynamicVariable); | |
DateTime dateTimeVariable = DateTime.Today; | |
dynamicVariable = (dynamic)dateTimeVariable; | |
Console.WriteLine(dynamicVariable); | |
// The expression returns true unless dynamicVariable has the value null. | |
if (dynamicVariable is dynamic) | |
{ | |
Console.WriteLine("d variable is dynamic"); | |
} | |
// dynamic and the as operator. | |
dynamicVariable = i as dynamic; | |
// throw RuntimeBinderException if the associated object doesn't have the specified method. | |
// The code is still compiling successfully. | |
Console.WriteLine(dynamicVariable.ToNow1); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment