c# - Using operators with certain types -
i trying equation answer < 10 && answer > 0.9. if true something.
if (answer < 10 && answer > 0.9) { } but error "operator '>' cannot applied operands of type 'decimal' , 'double'
in code,
var y = 1000000; var answer = x*y; x equal whatever user inputs in text box.
i don't know getting double honest. maybe answer becomes if becomes large? , how can make if statement work>
the var "answer" of type int , you're trying compare 10(of type int) , 0.9(of type double)
try:
var y = 1000000; var answer = convert.todouble(x*y); and
if (answer < 10.0 && answer > 0.9) and think work :)
Comments
Post a Comment