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
Post a Comment