Creating a dynamic variable C# with Example



Creating a dynamic variable C# with Example

dynamic foo = 123; 
Console.WriteLine(foo + 234); 
// 357 Console.WriteLine(foo.ToUpper()) 
// RuntimeBinderException, since int doesn't have a ToUpper method 
foo = "123"; 
Console.WriteLine(foo + 234); 
// 123234 
Console.WriteLine(foo.ToUpper()): 
// NOW A STRING 

0 Comment's

Comment Form

Submit Comment