How to set default input value in .Net Console App?

前端 未结 8 1429
时光取名叫无心
时光取名叫无心 2020-12-11 16:01

How can you set a default input value in a .net console app?

Here is some make-believe code:

Console.Write("Enter weekly cost: ");
string inp         


        
8条回答
  •  北荒
    北荒 (楼主)
    2020-12-11 16:37

    1. Add Reference to Assembly Library "System.Windows.Forms" to your Project
    2. Add SendKeys.SendWait("DefaultText") immediately after your Console.WriteLine command and before your Console.ReadLine command

     

    string _weeklycost = "";
    Console.WriteLine("Enter weekly cost: ");
    System.Windows.Forms.SendKeys.SendWait("135");
    _weeklycost = Console.ReadLine();
    

提交回复
热议问题