This is a homework question, which is why it might be somewhat odd(also apologize if the title isn't very good)
Assuming that v1 is a value type of type X that redefines ToString, is there any difference between using Console.WriteLine(v1) and Console.WriteLine(v1.toString())?
The simplest answer is that "yes, there's a difference". Obviously the important thing is that you know what that difference is though. I won't tell you that, but I'll tell you how to investigate it...
Console.WriteLine(v1)
and Console.WriteLine(v1.ToString())
in a Main
methodildasm
(or Reflector in IL mode) and look at the difference between the method invocations
Questions which you might want to think about and which might get you extra credit:
Console.WriteLine
could have been designed which would have removed any inefficiency you've noticed?If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With