-2

I was writing some code today and I noticed that Convert has a toString method, now I understand it has this because it inherits from the base object so the question is a little pointless because it inherently just has that built in no matter what, but just for the fun of it I wanted to ask - Would there ever be a time where this would be something you would want to do? I mean the point of Convert is to in this case take a string and turn it into a double, so why would you ever convert it back to a string?

Edit: I'm not saying this is pointless, I'm asking why you would ever use it because given my cursory inspection it seems pointless but obviously it is there for a reason and I'm curious, Not really sure why this is getting downvoted.

Trevor Hart
  • 993
  • 7
  • 26
  • 1
    You can also call `ToString()` with a format specifier. Could be useful if you want to change one representation into another. – Jeroen Vannevel Apr 14 '16 at 23:34

1 Answers1

1

This isn't necessarily pointless. It might be an attempt to normalize input strings. Convert.ToDouble will accept a variety of formats, but ToString should always output the same string given the same input. The ToString method being called is not on the Convert class, but on the double type, which is the result of calling Convert.ToDouble.

MarkPflug
  • 28,292
  • 8
  • 46
  • 54
  • Right, I worded my question poorly I think, I was more asking why this would ever be used, not really why there is a ToString method associated with it, thanks for your insight :) – Trevor Hart Apr 14 '16 at 23:38