Answer
Every class in C# inherits a ToString method from the base Object class, but by default it simply returns the full name of the type, which is rarely useful for debugging or displaying information to users. Overriding ToString lets you return a meaningful, readable string representation of an object's actual data, which is especially helpful when logging objects, displaying them in a user interface, or debugging, since it shows relevant details instead of a generic type name.
public class Product {
public string Name { get; set; }
public decimal Price { get; set; }
public override string ToString() {
return $"{Name}: ${Price}";
}
}
Console.WriteLine(new Product { Name = "Pen", Price = 2.50m });Real-world example A logging system that writes exception details to a file calls ToString on custom exception related objects, and because those classes override ToString with meaningful details, the resulting logs are immediately useful for debugging instead of showing generic type names.