When is it safe to use implicit casting?
Use Case: I'm working with a set of com objects that need to be taken care of specially (Marshal.ReleaseComObject). Is it OK to create a wrapper class that implicitly converts back to the actual com object wrapped?
What are some situations when I shouldn't use implicit casting?
You should use implicit casting when (and only when) you are sure that:
1. No information (data) is lost (or can be lost) while converting.
2. No exception can be thrown.
3. No silent fail can occur (you will receive degenerated data).
I usually summarize these points as "never", but ironically your use case actually sounds like a goer...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With