Why does the string data type have a .ToString() method?
Why does the string data type have a .ToString() method?
Share
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.
The type
System.String, like almost all types in .NET, derives fromSystem.Object.Objecthas aToString()method and soStringinherits this method. It is a virtual method andStringoverrides it to return a reference to itself rather than using the default implementation which is to return the name of the type.From Reflector, this is the implementation of ToString in
Object:And this is the override in
String: