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


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;

Samual Sam
Samual Sam

Learning faster. Every day.

Updated on: 22-Jun-2020

1K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements