2 ms·
C# has "dynamic" type. All calls on it are late-bound.
by kgeist 5y ago
C# has "dynamic" type. All calls on it are late-bound.
- ComputerGuru 5y agoDynamic didn’t really go anywhere, but more appropriate examples that have now pervaded the language are await in general and IDisposable for ref struct. If it has a GetAwaiter it can be awaited, with no interface. If it has a Dispose() it can be disposed with no interface.
- Zababa 5y ago> If it has a GetAwaiter it can be awaited, with no interface. If it has a Dispose() it can be disposed with no interface. I don't know much about C# but how is this dynamic? Are those methods often added at runtime?
- useerup 5y agoIt's not dynamic. It is structural typing
- UglyToad 5y agoAs far as I understand it it went to wherever there are still poor souls writing COM Interop stuff primarily. Luckily I've never had to touch it so outside of Dapper for SQL I've never really had cause to use dynamic. I imagine there are Windows shops using it heavily though.
- mgdlbp 5y agoInterestingly, this sort of structural typing was already present in C# 1.0 with the foreach statement allowing anything with a GetEnumerator() method that returns something that looks like an IEnumerator. This was discussed in 2011 in a StackOverflow question [0], including a link to a blog post by one of the language designers [1]. [0] https://stackoverflow.com/questions/6368967/duck-typing-in-the-c-sharp-compiler https://stackoverflow.com/questions/6368967/duck-typing-in-t... [1] https://web.archive.org/web/20120126033827/http://blogs.msdn.com/b/ericlippert/archive/2011/06/30/following-the-pattern.aspx https://web.archive.org/web/20120126033827/http://blogs.msdn...