reading text and using if on same line.


hi, hope can answer me question here:

if want use console.readline(); go 1 line down. use information on same line.

for example if want take 25% of number use:

console.write("write number: ");

int x = convert.toint32(console.readline());

x /=4

console.write("\t25%: "+x);

on screen if write 100 this:

write number: 100

25%: 25

what is:

write number: 100 25%: 25

am able make that? 


the console console recognizes return in readline() method , moves down 1 row on terminal.  prevent happening use console.readkey() , use key the f1 end data entry.  try soemthing this

using system; using system.collections.generic; using system.linq; using system.text; using system.io; namespace consoleapplication1 {     class program     {         static void main(string[] args)         {             console.write("enter number (use f1 terminate input) : ");             char input = '\0';             string number = "";             consolekeyinfo key;             while (true)             {                 key = console.readkey();                 if (key.key == consolekey.f1)                     break;                 input =  key.keychar;                 if (char.isdigit(input))                 {                     number += input;                 }             }             console.writeline("  25%: 25");         }     } }


jdweng



Visual Studio Languages  ,  .NET Framework  >  Visual C#



Comments

Popular posts from this blog

Azure DocumentDB Owner resource does not exist

job syspolicy_purge_history job fail in sqlserver 2008

Trying to register with public marketplace error with 'Get-AzureStackStampInformation'