Dynamic is a new keyword , which is include in c# 4.0 version in 2010. Dynamic keyword manage by the Dynamic Language Runtime (DLR), which work as a Common Language Runtime (CLR). Dynamic variable not define as type, because dynamic variable manage by the Dynamic Language Runtime (DLR). Dynamic variable is declared as having type dynamic, operations on these value are not done or verified at compile time, but instead happen entirely at runtime.
Example
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace dynamic_variable_in_c_sharp
{
class Program
{
static void Main(string[] args)
{
dynamic a = 10; //Create Dynamic variable a, which value assige as int type
dynamic b = "Hello"; //Create Dynamic variable b, which value assige as string type


RayMir SorPosted Jul 8, 2014, 4:26 AM
when I'm compiling this ,it's showing error:-One or more types required to compile a dynamic expression cannot be found. Are you missing references to Microsoft.CSharp.dll and System.Core.dll?
Former memberPosted Aug 30, 2013, 12:46 PM
nice thought
Ken HPosted Aug 30, 2013, 8:37 AM
It can not seem to work.
Prasenjit DeyPosted Aug 30, 2013, 8:33 AM
Hi, If I add two integer value as a dynamic variable, then is the result always should be stored in an another dynamic variable? Because when I run that program, then when I show the value of a c result directly, then it is just concatenate that two variables, not adding. i.e. not behaving like a integer, behaving like string. But when I store that result in an another dynamic variable then result coming is correct. Confused about that matter