I have used the dynamic and the object type interchangeably. Is there any difference between these two types? Is there any performance implications of using one over the other? Which one of these is more flexible?
I have used the dynamic and the object type interchangeably. Is there any difference
Share
They’re hugely different.
If you use
dynamicyou’re opting into dynamic typing, and thus opting out of compile-time checking for the most part. And yes, it’s less performant than using static typing where you can use static typing.However, you can’t do much with the
objecttype anyway – it has hardly any members. Where do you find yourself using it? When you want to write general purpose code which can work with a variety of types, you should usually consider generics rather thanobject.