I have one question..
Which has more effective performance? Or which take less time to execute and Why?
session["var"].ToString()
or
(string)session["var"]
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
ToString() is a method and (string) is casting (Explicit). IMO casting is always fast
.ToString() can be called from any object. This method is inherited from object class and can be overloaded
.(string) is a cast, Its not a function call. It should be used when it is sure that the object is already in string, it will throw an exception when it can’t convert to string including null