DEV Community

Discussion on: Interview question(s) about concepts you don't interact with often, if at all

Collapse
 
dki19t profile image
Anton Khokhlov

Dynamic works well when you need to interact with old windows API like COM. You can use it whenever you don't know how the result of an operation will look like, for example, a call to poorly designed and documented API.

You can think about it as a dictionary, where the key is the name of some object's property and the value is the value of that property. When you work with JSON, for instance, you can add or remove properties to it. I would place dynamic near the goto operator. It's powerful, but only when you know perfectly what you are doing.

Some people mean all function-as-a-variable-of-some-kind stuff with the word "delegate." The main benefit of delegates is the ability to reference a piece of logic somewhere in your app. The simplest way to implement the "strategy" pattern in C# is probably to use delegates.

When somebody asks me a question about unfamiliar stuff, I admit that I don't know what it is / how to work with it / read about it long ago and never used it. For me, an interview is also a way to test my knowledge. Any question is a hint to revise something. The worst thing is when you know the answer, but you have failed to explain it to the interviewer.

Collapse
 
kj2whe profile image
Jason

Thank you for such a great response! You now have a new follower :D