© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•2y ago
Harzminers

Implementing an extendable Calculator Console Application

I would like to create a console application that can parse algebraic terms with basic operators and values (int, decimal).
However, i am unsure regarding the correct approach to this.
My initial idea is to differentiate Values (implementing IValue interface) and Operators (IOperator interface) which are expected to alternate in a Term, starting and ending with an IValue (Brackets in a Term contain a Subterm/another Term, which would be considered a Value)

I could define classes for int, decimals etc named intValue etc., but i was hoping i could define a generic way of adding, subtracting etc. in my Operators (Addition, Subtraction etc.). However, the only interface that seems to allow these operations i found is INumber<T>, which would still require multiple methods for int/int , decimal/decimal etc. operations.

Any pointer regarding this problem, the general approach or good learning resources would be greatly appreciated.
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Basic calculator application
C#CC# / help
2y ago
✅ C# Console App Calculator Help
C#CC# / help
2mo ago
Help making a console calculator
C#CC# / help
3y ago