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!
4 Replies
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)
Thanks! I thought that you always needed else when using an if function
Nope 🙂
that's cool! it took 1 minute to get help here, thanks alot @sinfluxx!