c# - Basic Code (first time coding) errors (visual studio 2015 for desktop express) -


        console.writeline("type number, number!");         consolekeyinfo keyinfo = console.readkey();          if (keyinfo.keychar -- 'a')         {             console.writeline("thats not number, knock off!");         }          console.writeline("did press {0}", keyinfo.keychar.tostring());     } } 

i'm getting below errors above code, how can fix these?

cs1026 ) expected cs1002 ; expected cs0200 property or indexer 'consolekeyinfo.keychar' cannot assigned -- read cs1513 } expected 

consolekeyinfo.keychar gets unicode character represented current consolekeyinfo object. it's read property , means can't modify value of property.

by looking code, seems want check character a in if condition. use comparison operator(equality operator) == this

if (keyinfo.keychar == 'a') 

Comments

Popular posts from this blog

php - Admin SDK -- get information about the group -

dns - How To Use Custom Nameserver On Free Cloudflare? -

Python Error - TypeError: input expected at most 1 arguments, got 3 -