C# dynamic

main program


 public static void test()
 {
     var a = 45;
     a = a + 2;

     dynamic b;
     b = 5;
     Console.WriteLine($"b: {b} [{b.GetType()}]");

     b = 5 + .1d;
     Console.WriteLine($"b: {b} [{b.GetType()}]");

     b = 5;
     Console.WriteLine($"b: {b} [{b.GetType()}]");
 }
 

console

b: 5 [System.Int32] b: 5,1 [System.Double] b: 5 [System.Int32]