What is the difference between dynamic type variables and object type variables?

CsharpProgrammingServer Side Programming

You can store any type of value in the dynamic data type variable. Type checking for these types of variables takes place at run-time.

The Object Type is the ultimate base class for all data types in C# Common Type System (CTS). The object is an alias for System. Object class. The object types can be assigned values of any other types, value types, reference types, predefined or user-defined types.

Dynamic types are similar to object types except that type checking for object type variables takes place at compile time, whereas that for the dynamic type variables takes place at runtime.

Example of Dynamic Type −

dynamic z = 100;

Example of Object Type −

object obj = 100;
raja
Published on 16-Aug-2018 09:42:05
Advertisements