2
Answers

Dynamic data type

Maha

Maha

10y
652
1
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)