The article https://habr.com/ru/post/143925/ describes how delegates can be used to call + - / * methods (all with two variables) on a self-written calculator.

How to add methods with one variable (for example, factorial of a number) or with three variables (for example, determining the volume of a rectangular parallelepiped based on the lengths of three edges: x * y * z)?

  • Your attempts to solve your problem yourself? - tym32167 February
  • Overloading the DefineOperation() method & adding 2 necessary dictionaries will help you. - Bulson

1 answer 1

without changing the program can not add. try the Interpreter pattern
if you don’t need to make a calculator so that it parses the string and, based on it, you will be “counted” by the code, then you can stop there
there will be a bit more trouble with the parser (and here you will be already “juggling” with operators - not to forget about the priority of operations, create operations for any number of parameters, numbers of any kind)