c# - What interface or method should my class implement to print what I want in Console.WriteLine? -
i have object of class f. want output contents of object using console.writeline quick , dirty status updates this:
console.writeline(objectf);
this prints out name of class console:
f
i want overload somehow can instead print out useful information object , properties.
i have workaround already: overload tostring method in class , call: console.writeline(objectf.tostring());
but rather have simpler syntax. ideas?
console.writeline(objectf)
should work, if overloaded tostring
. when framework needs convert object string representation, invokes tostring
.
public override string tostring() { // replace line below code return base.tostring(); }
Comments
Post a Comment