Alex Rivera | Logout

dynamic vs object type

Asked 2010-08-09T18:08:32.557
67

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?

Edit
Report

1 Answer

60

They're hugely different.

If you use dynamic you'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 object type 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 than object.

answered 2010-08-09T18:10:08.553

Your Answer