Click here to Skip to main content
15,895,667 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello I trying to create Mathematical example wtihout mark. In WPF Apllication in xaml I create radiobutton according to which the example is chosen (addition, multiplication, subtraction). But I don´t know how to create total sum.

What I have tried:

C#
int total =  (prvnic, znam, druhyc);

int total is total sum of counting
prvnic is first nuber, which is randomly generated
znam is mark which is selected by radiobutton
druhyc is second number, which is randomly generated

I ask for your advice. It's probably primitive, but somehow I have no idea.
Thank you
Posted
Updated 20-Apr-21 0:34am

You need to write the code to calculate it. So create a switch block or set of if/else statements to perform the appropriate calculation based on the operator (+, -, *, /). See C# operators and expressions - C# reference | Microsoft Docs[^].
 
Share this answer
 
Comments
dejf111 20-Apr-21 4:56am    
In fact, it is true. Thank you very much!!!
You can also use a math parser that parses a string, see CodeProject article: Math Parser .NET C#[^]

Or wait until Mark has left the room :)
 
Share this answer
 
v2

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