Answer the question
In order to leave comments, you need to log in
How does Console.WriteLine() take a StringBuilder object?
I know that you can print a number, a string, even a function (more precisely, its return value).
But is it possible to print an object?
Does an object return a value?
How is this possible?
StringBuilder x=new StringBuilder("текст");
Console.WriteLine(x);
Answer the question
In order to leave comments, you need to log in
Read the book about redefining ToString
public class Test
{
private string _text;
public Test(string text)
{
this._text = text;
}
public override string ToString()
{
return _text;
}
}
var x = new Test("текст");
Debug.WriteLine(x);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question