Check out example codes for "difference between dynamic and var". It will help you in understanding the concepts better.

Code Example 1

Type of 'a' is : System.Char 
Type of 'b' is : System.String 
Type of 'c' is : System.Double 
Type of 'd' is : System.Boolean 
Type of 'e' is : System.Int32

Code Example 2

// C# program to illustrate how to get the 
// actual type of the dynamic type variable 
using System; 
  
class GFG { 
  
    // Main Method 
    static public void Main() 
    { 
  
        // Dynamic variables 
        dynamic val1 = "GeeksforGeeks"; 
        dynamic val2 = 3234; 
        dynamic val3 = 32.55; 
        dynamic val4 = true; 
  
        // Get the actual type of 
        // dynamic variables 
        // Using GetType() method 
        Console.WriteLine("Get the actual type of val1: {0}", 
                                  val1.GetType().ToString()); 
  
        Console.WriteLine("Get the actual type of val2: {0}", 
                                  val2.GetType().ToString()); 
  
        Console.WriteLine("Get the actual type of val3: {0}", 
                                  val3.GetType().ToString()); 
  
        Console.WriteLine("Get the actual type of val4: {0}", 
                                  val4.GetType().ToString()); 
    } 
}

Code Example 3

// C# program to illustrate the concept 
// of the implicitly typed variable 
using System; 
  
class GFG { 
  
    // Main method 
    static public void Main() 
    { 
  
        // Creating and initializing 
        // implicitly typed variables 
        // Using var keyword 
        var a = 'f'; 
        var b = "GeeksforGeeks"; 
        var c = 30.67d; 
        var d = false; 
        var e = 54544; 
  
        // Display the type 
        Console.WriteLine("Type of 'a' is : {0} ", a.GetType()); 
  
        Console.WriteLine("Type of 'b' is : {0} ", b.GetType()); 
  
        Console.WriteLine("Type of 'c' is : {0} ", c.GetType()); 
  
        Console.WriteLine("Type of 'd' is : {0} ", d.GetType()); 
  
        Console.WriteLine("Type of 'e' is : {0} ", e.GetType()); 
    } 
}

Code Example 4

Get the actual type of val1: System.String
Get the actual type of val2: System.Int32
Get the actual type of val3: System.Double
Get the actual type of val4: System.Boolean

Learn ReactJs, React Native from akashmittal.com