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

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -