which among these is better with respect to performance?

c#, performance

Solution

The bottom line is that writing to the console is bound to dominate the performance here - even if you're redirecting it to some sort of "null" sink.

The difference, IMO, is that

Console.WriteLine(i);

is simpler to read... so that's what I'd use until I'd proven that using the slightly-less-readable form gave a concrete benefit. In this case, neither form would end up boxing `i` when it's an integer, because there's an overload for `WriteLine(int)`. A slightly more interesting question is between these two lines:

Console.WriteLine("Some format {0} stuff", i);
Console.WriteLine("Some format {0} stuff", i.ToString());

The first form will box the integer; the second won't. The difference in performance? Nothing significant.

Problem

what is the difference between these two statements? which is better with respect to performance? ``` Console.Writeline(i); Console.Writeline(i.toString()); ``` where i is a string or an integer.

Original source