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

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -