I have performed some research on a variety of conversion methods, and have arrived on the usage of explicit or implicit operators.
Noting that System.Security.SecureString is a sealed class (it can not be inherited from), is it possible to write an explicit or implicit operator that is able to perform conversion between a System.Security.SecureString and a System.String (utilizing the methodology described here).
For instance, I do know you must write the operator in a (partial) class of the object being converted. Therefore, I figured the best way to do this was to inherit the class, and write the necessary operators.
Is it possible to a) perform a conversion using an explicit or implicit operator for a System.Security.SecureString to a System.String, b) perform a conversion of a class object who's class is sealed?
If not, is there another method outside of utilizing a class method, that will perform the conversion?
Please provide a pragmatic answer assuming I am a consumer of Microsoft's products.
Noting that
System.Security.SecureStringis a sealed class, is it possible to write an explicit or implicit operator that is able to perform conversion between aSystem.Security.SecureStringand aSystem.String?
Yes, if you are a member of the Base Class Library team you can do so. Of course, doing so is a bad idea.
If you are not a member of the BCL team then no. You need to be able to change the source code of one of the two classes.
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