wasAsked.

Explain method overloading.

PwC · Role not specified · technical

Published

Asked in 2026 · C#

Community answers

Posted by wasAsked editorial collection

Method overloading defines methods with the same name but different parameter lists. The compiler selects the best applicable overload using compile-time types and conversion rules. Return type alone cannot distinguish overloads. Example: public string Format(decimal value) => value.ToString("0.00"); public string Format(decimal value, string currency) => string.Concat(currency, " ", value.ToString("0.00")); public string Format(decimal value, CultureInfo culture) => value.ToString("C", culture); Avoid overloads where null, optional parameters, params arrays, or similar numeric conversions make calls ambiguous. Overloading is compile-time polymorphism; overriding is runtime dispatch through a virtual or abstract contract.

Backbencher Developer · · 0 likes

Sign in to add your answer

Related interview topics