Different between dynamic type variables and object type variables in C#?
Different between dynamic type variables and object type variables in
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
Different between dynamic type variables and object type variables in C#?
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Muhammad Imran AnsariRank #326 · 7.6K reputationPosted Oct 23, 2022, 10:20 AM EDT
Following are the some differences between Object and Dynamic types.
Object Type:
It can store any kind of value because the object is the base class of all type in .NET framework and compiler has little information about the object type.
Need to cast object variable to original type to use it and performing desired operations.
Dynamic Type:
It can store any type of the variable, similar to the old VB language variable.
It is not type safe i.e. Compiler doesn't have any information about the type of variable.
Casting is not required but you need to know the properties and methods related to stored type.
Further, you can read with example from the following link:
https://www.c-sharpcorner.com/UploadFile/rohatash/difference-between-object-and-dynamic-keyword-in-C-Sharp/