ToString in C#: Override It and Format Numbers, Dates and Enums (.NET 10)
If you need to print or log an object, Console.WriteLine(order) is the obvious first try, and it prints Bookstore.Order instead of the order. That’s the default ToString in C#: unless a type overrides it, it returns the type’s full name. The fix is to override ToString() in your class (or use a record), and to … Read more >>