Click here to Skip to main content
14,698,687 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want to add or subtract or multiply values in two text box text but the operator is also in textbox text . I have shifting from to C#.

Error CS0019 Operator '&' cannot be applied to operands of type 'string' and 'string'

What I have tried:

TbResult.Text = TbResult.Text & TbOperator.Text & TbInput.Text;      
Updated 8-Mar-20 9:30am

1 solution

That is VB string concatenation, so nothing to do with your question, or C#. You should capture the numbers into variables using the relevant xxx.TryParse method (where xxx is Int or Double as required). You can then use a switch block to perform the appropriate mathematical function and pass the result to the final text box.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900