Published: Monday 16 October 2023
Inheriting in C# is a great way to provide parent properties and methods to a number of different classes.
This means that common functionality can be shared across many different areas of an application reducing code bloat.
However, there are instances where inheriting can throw compile errors.
Take these classes:
public class Currency : CurrencyBase, CurrencyParent
{
}
public class CurrencyBase
{
}
public class CurrencyParent
{
}
The Currency
class is inheriting both the CurrencyBase
and CurrencyParent
class. Why will this code not compile?