pBox.SecurePassword
will return an new instance of secure string each time you read the property. You can validate it by calling GetHashCode
on pBox.SecurePassword
multiple times.
You'll also notice that using Visual Studios "Make object id" does not display #X, because its an new instance every time you hover with the mouse.
When creating a reference to a SecureString
object into a local variable it is the same instance that you called MakeReadOnly()
on, so it behaves as expected.