Matt Higgins

Matt Higgins

  • NA
  • 32
  • 24.6k

When and when not to use the ToString() method

Nov 12 2012 6:53 AM
Hi

I've got some code which works surprisingly well.

When I use the MessageBox.Show command, sometimes I can get a away without using the To String() method. Anybody can say why this snippet of code works ok please :-

decimal averageIteration = iterationsTotal / iterations.Length;
int maxIterations = iterations.Max();

MessageBox.Show("The average number of iterations needed to win are " + averageIteration + "\n" +
                                "The High number was " + maxIterations + "\n" +
                                "The Lowest number was " + iterations.Min());

The code above does not have any trouble outputting an int or decimal types. No need to even use the ToString() method.

Thanks to anyone who can help answer this for me

Cheers

Matt


Answers (1)