How can I add the second number to the equal button? [duplicate]
Your code is already most of the way there. equalButton_Click
works by applying the operation specified by function
and second
to first
. So if you say 1 + 1 =
, you get a result of 2. If you want to hit =
again and get the result from 2 + 1 =
, all you'd need to do is have your code put result
into first
and you've (conceptually) got a solution that works.
Having said that, the constant conversions between string
and double
, plus floating-point precision errors are going to ensure it doesn't work particularly well for anything complicated. If you want this code to be anything more than a toy, look into better methods of dealing with exact numbers.