4
Recently, I received the following notice from Visual Studio in a code similar to the image:
I understand what he wanted to say: there is a reference comparison of the two values (the session and the string "test"), and this will always return false
, because any value stored in Session
will never be referenced in the right string.
But why does it happen? Because Visual Studio was unable to make the comparison without a prior conversion?
PS: The same goes for ViewState
tries to put
Session["teste"].ToString()
– Jeferson Almeida
Yes, I know it works, but I’d like to know why you need this conversion
– Artur Trapp