c# - Understanding error "name does not exist in the current context" -
i using c#. have error: "the name 'clerk' not exist in current context" don't understand. tried lots of solution on not working.
console.writeline("enter name:"); string name = console.readline(); console.writeline("working days:"); int days = convert.toint32(console.readline()); console.writeline("working hours:"); int hour = convert.toint32(console.readline()); console.writeline("job designation:"); string job = console.readline(); if (job == manager) { console.writeline("salary is:" + (days * hour * 200)); } else if (job == clerk ) { console.writeline("salary is:" + (days * hour * 50)); } else { console.writeline("no record"); } } }
}
you're forgetting double quotes in if statements (see below)
console.writeline("enter name:"); string name = console.readline(); console.writeline("working days:"); int days = convert.toint32(console.readline()); console.writeline("working hours:"); int hour = convert.toint32(console.readline()); console.writeline("job designation:"); string job = console.readline(); if (job == "manager") { console.writeline("salary is:" + (days * hour * 200)); } else if (job == "clerk" ) { console.writeline("salary is:" + (days * hour * 50)); } else { console.writeline("no record"); }
Comments
Post a Comment