Maha

Maha

  • NA
  • 0
  • 326k

Dynamic data type

Apr 23 2014 10:03 AM
In this following example dynamic data type is behaving in a contradictory manner. Please explain the reason.

Dynamic data type multiplying two variables in the 1st output and adding two variables in the 2nd output. Problem is highlighted.

using System;
class Program
{
static void Main(string[] args)
{
dynamic d1, d2;
d1 = "A";
d2 = 1;
Console.WriteLine(d1 + d2);//A1


d1 = 10.01;
d2 = 1;
Console.WriteLine(d1 + d2);//11.01

Console.ReadKey();
}
}


Answers (2)