.
Session("UserName") = "Sally"
Dim userName As String = Session("UserName")
Do i need to convert the session variable to str开发者_如何学编程ing if i wanna follow "good coding practices"?
Ex:
Session("UserName") = "Sally"
Dim userName As String = Convert.ToString(Session("UserName"))
IMO, you should be using
Option Strict On
Option Explicit On
at all times, it makes the compiler yell at you when you cast implicitly or use undeclared identifiers.
Yes as a good practice and if you want to assign to a new variable:
Dim userName As String = Session("UserName")
Otherwise you can use it directly:
Print Session("UserName")
Note that value "Sally"
(wrapped in quotes) is a string.
精彩评论