This extension facilitates the calculation of both simple interest and compound interest.
To install the package via NuGet, you can use the following command:
dotnet add package InterestExtensionsYou can also visit the NuGet package page for more information and to download the package.
- Simple and compound interest calculations
- Overloads for different compounding periods (yearly, monthly, daily)
- XML documentation for IntelliSense and API docs
- Thoroughly unit-tested
- .NET 8 and above supported
using InterestExtension;
using InterestExtension.Enums;
decimal principal = 100m;
decimal interestRate = 0.004m;
int period = 7;
// Calculate simple interest (final amount)
decimal simple = principal.CalculateSimpleInterest(interestRate, period);
// Calculate simple interest amount (just the interest earned)
decimal simpleAmount = principal.CalculateSimpleInterestAmount(interestRate, period);
// Calculate compound interest (final amount, annual compounding)
decimal compound = principal.CalculateCompoundInterest(interestRate, period);
// Calculate compound interest (monthly compounding)
decimal compoundMonthly = principal.CalculateCompoundInterest(interestRate, period, InterestPeriod.Monthly);
// Calculate only the interest earned
decimal earned = principal.CalculateCompoundInterestAmount(interestRate, period, InterestPeriod.Daily);Contributions are welcome! If you encounter any issues or have suggestions for improvements, feel free to open an issue or submit a pull request.