C
C#•15mo ago
EGGET

Need help with if function

Hello, Im a beginner in C# and I need help with my code. I don't want line 99 to write out anything if coffee is false but it stills write out "Coffee = 0kr". How does the if function works here? Is it not working because of line 97 I got totalCoffeePrice? Thanks in advanced!
No description
No description
4 Replies
SinFluxx
SinFluxx•15mo ago
Couple things You don't have to have an else statement if you don't need it When you're comparing values, make sure you use == not = The green line under your if statement in line 96 should be warning you about that Also with boolean values you can simply do if(coffee) or if(!coffee)
EGGET
EGGETOP•15mo ago
Thanks! I thought that you always needed else when using an if function
SinFluxx
SinFluxx•15mo ago
Nope 🙂
EGGET
EGGETOP•15mo ago
that's cool! it took 1 minute to get help here, thanks alot @sinfluxx!
Want results from more Discord servers?
Add your server