Which method is actually called ultimately when Console.WriteLine( ) is invoked

A) Append( )
B) AppendFormat( )
C) Tostring( )

Showing Answers 1 - 8 of 8 Answers

I think String.Format() is called that ultimately calls StringBuilder.AppendFormat() and StringBuilder.Append() .AppendFormat in turn calls ToString().

  Was this answer useful?  Yes

Seeker911

  • Jun 15th, 2011
 

The answer is C

Ultimately ToString() is called. Depending on what overload is used when calling Console.WriteLine() either Append or AppendFormat will be called called then ToString()

  Was this answer useful?  Yes

LordAlex

  • Nov 4th, 2011
 

Does some one dig the code with Reflector??

In deed, according the Reflector, see code....

it's clear only ToString() can be called.

Code
  1. public virtual void System.TextWriter.WriteLine(string format, params object[] arg)

  2. {

  3.     this.WriteLine(string.Format(this.FormatProvider, format, arg));

  4. }

  5.  

  6.  

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions