✅ why dispose call is the latest in the chain?
Actually I have two questions here:
1. How actually duck typing works? Why I can do this:
but can't do the same with class, class requires to inherit
IDisposable
and it is strange:
2 question is: why dispose call is the latest in the chain? for example:
and output will be:
Created Factory!
Hello from class!
Hello from ref struct!4 Replies
It makes sense? If
SimpleClass
depends on RefStruct
, it might be an error if RefStruct
is disposed while SimpleClass
is still aliveok I understand
thanks
what about duck typing?
What about duck typing?
Ah I see what you mean
ref structs can't implement interfaces, so we have to go down the route of duck typing there
But classes can implement interfaces, so there's no need for duck typing
hm interesting
thanks for helping me