Problems with the consolekeys string C# -
i have question code, supposed write i'm typing.
consolekeyinfo = console.readkey(); if (a.key == consolekey.spacebar) { console.write(" "); } else if (a.key == consolekey.enter) { console.writeline(""); } else { string b = a.key.tostring(); console.write(b); } if i'm clicking on d example prints: dd
but if check b.length equals 1. , if try print b[0] still printing dd. how possible? , how can fix it?
the readkey method both reads key , displays user. hence when hit "d" displays "d", returns consolekeyinfo value , code displays "d". results in "dd" display.
to stop pass true readkey prevent display
consoleinfo = console.readkey(true);
Comments
Post a Comment